share: • Language, Standard Library, CoreFoundation, Dispatch • Foundation on Linux is new Swift implementation • Available on Darwin as “SwiftFoundation”
new Swift APIs for libraries • New Swift API for Dispatch • New Swift(ier) APIs for Foundation • Implicit bridging being replaced with explicit bridging
APIs Kitura Server Project Swagger REST API Deploy Deploy • Same module on client and server • Local or remote API calls • Automatically created Swagger APIs
framework written in Swift Why is this cool? Empower a new generation of native mobile developers to write and deploy code into the Cloud. Developer Benefits ? Delivers core technologies needed to stand up enterprise apps on the server Enables developers to create a web application in Swift and deploy these servers on Linux and the Cloud. http://github.com/ibm-swift/kitura 10
& Interfaces Swift Libraries SwiftyJSON Kitura-redis Swift Binary Foundation Package Manager C Libraries Dispatch HttpParser HiRedis CURL PCRE2 Pluggable Components
Sources │ └── main.swift └── Tests $ mkdir myProject 2. Next, initialize this project as a new Swift package 1. First, we create a new project directory $ cd myProject $ swift build --init Basic Swift package directory structure:
Kitura.run() let router = Router() router.get("/hello") { request, response, next in response.status(.OK).send("<h1>Hello, World!</h1>").end() } 6. Create and start an HTTPServer: 4. Add a router and a path: router.get("/hello.json") { request, response, next in response.status(.OK).send(json: JSON(["Hello": "World!"])).end() } 5. Add a JSON data route
= Router() router.get("/hello") { request, response, next in response.status(.OK).send("<h1>Hello, World!</h1>").end() } router.get("/hello.json") { request, response, next in response.status(.OK).send(json: JSON(["Hello": "World!"])).end() } Kitura.addHTTPServer(onPort: 8090, with: router) Kitura.run() 7. Sources/main.swift should now look like this: