Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Server Side Swift question

Shinichi Goto
October 21, 2015
940

Server Side Swift question

Shinichi Goto

October 21, 2015
Tweet

Transcript

  1. To work with server-side app • ࠷௿ݶ • HTTP Server

    • Template Engine • DBI, DB driver 9 GRMustache Swifter, Taylor
  2. HTTP server engine / fw • Swifter • ͦͦ͜͜੔ͬͯ͸͍Δ •

    https://github.com/glock45/swifter • Taylor • ͔ͳΓബ͍ & ·ͩػೳἧͬͯͳ͍ • GoͷMartiniϥΠΫʹॻ͚Δ • https://github.com/izqui/Taylor 11
  3. Swifter 12 import Swifter let server = HttpServer() server["/"] =

    { request in return .OK(.HTML("Hello World!")) } var e: NSError? if !server.start(3002, error: &e) { print("Server start error: \(e)") } else { NSRunLoop.mainRunLoop().run() }
  4. Swifter 13 import Swifter let server = HttpServer() server["/"] =

    { request in return .OK(.HTML("Hello World!")) } var e: NSError? if !server.start(3002, error: &e) { print("Server start error: \(e)") } else { NSRunLoop.mainRunLoop().run() }
  5. Taylor 14 import Taylor let server = Taylor.Server() server.get("/") {

    req, res, cb in res.bodyString = "Hello World!" cb(.Send(req, res)) } do { try server.serveHTTP(port: 3001, forever: true) } catch let e { print("Server start failed \(e)") }
  6. Taylor 15 import Taylor let server = Taylor.Server() server.get("/") {

    req, res, cb in res.bodyString = "Hello World!" cb(.Send(req, res)) } do { try server.serveHTTP(port: 3001, forever: true) } catch let e { print("Server start failed \(e)") }
  7. Swifter or Taylor • ΠϯλʔϑΣΠε͸ Taylor > Swifterʢݸਓత ʹ͸ʣ •

    ͕ɺTaylor͸·ͩ৭ʑ੔ͬͯͳ͍ • Swifter => CarthageରԠͯ͠ͳ͍ • αʔόαΠυతʹѻ͍ʹ͍͘ʁ 16
  8. Swifter or Taylor • ΠϯλʔϑΣΠε͸ Taylor > Swifterʢݸਓత ʹ͸ʣ •

    ͕ɺTaylor͸·ͩ৭ʑ੔ͬͯͳ͍ • Swifter => CarthageରԠͯ͠ͳ͍ • αʔόαΠυతʹѻ͍ʹ͍͘ʁ 17 cocoapods-rome
  9. cocoapods-rome 22 APP_ROOT ├─ Podfile ├─ Pods/ │ ├─ Headers/

    │ ├─ Local Podspecs/ │ ├─ Pods.xcodeproj/ │ ├─ Swifter/ │ ├─ Target Support Files/ │ ├─ Manifest.lock ├─ Rome/ │ └─ Swifter.framework/ ├─ main.swift …
  10. cocoapods-rome 23 APP_ROOT ├─ Podfile ├─ Pods/ │ ├─ Headers/

    │ ├─ Local Podspecs/ │ ├─ Pods.xcodeproj/ │ ├─ Swifter/ │ ├─ Target Support Files/ │ ├─ Manifest.lock ├─ Rome/ │ └─ Swifter.framework/ ├─ main.swift …
  11. cocoapods-rome 24 APP_ROOT ├─ Podfile ├─ Pods/ │ ├─ Headers/

    │ ├─ Local Podspecs/ │ ├─ Pods.xcodeproj/ │ ├─ Swifter/ │ ├─ Target Support Files/ │ ├─ Manifest.lock ├─ Rome/ │ └─ Swifter.framework/ ├─ main.swift … swift -F Rome main.swift