Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introduction of Swift HTTP APIs
Search
Shun Takebayashi
June 27, 2017
Programming
360
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction of Swift HTTP APIs
Shun Takebayashi
June 27, 2017
More Decks by Shun Takebayashi
See All by Shun Takebayashi
はじめてのSwift Server API / Beginning Swift Server API
takebayashi
1
720
The Ecosystem of Web Development with Swift
takebayashi
4
1.3k
Other Decks in Programming
See All in Programming
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
2.3k
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
140
一人だけ、Kiroが静止する日
hideg
0
130
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.3k
AI活用は、個人から組織へ|マルチプレイヤーエージェントハーネス「QM」の社内活用事例 / AI use is moving from individuals to orgs
rkaga
1
310
スマートフォンでモールス信号を送受信する 〜スマートフォンのLEDとカメラで作る光通信の設計と実装〜
atsuki_seo
0
210
Heart of Swift Concurrency
koher
0
1.1k
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.5k
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
420
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
250
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.6k
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
840
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
530
Bash Introduction
62gerente
615
220k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
540
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
550
We Are The Robots
honzajavorek
0
380
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
710
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
Introduction of Swift HTTP APIs Shun Takebayashi
History of Server-Side Swift
History of Server-Side Swift (Dec 2015) • Apple open-sourced Swift
History of Server-Side Swift ( - Mid 2016) • App
frameworks • Perfect • Kitura • No standard APIs • Third-party API specifications • Nest • OpenSwift / S4
The Ecosystem of Web Development with Swift Shun Takebayashi takebayashi
https://speakerdeck.com/takebayashi/the-ecosystem-of-web-development-with-swift
History of Server-Side Swift (Oct 2016) • Apple announces Server
APIs Work Group • Working on 3 layers: • Base networking • Security / Encryption • HTTP / WebSocket
͜Ε͔Β͡ΊΔ αʔόʔαΠυ Swift Tokyo Server Side Swift Meetup #7 @
Speee Lounge - 2017.5.26 https://speakerdeck.com/jp_pancake/korekarahazimerusabasaido-swift
What are HTTP APIs?
HTTP APIs are NOT… • Web application frameworks • Stable
specification
HTTP APIs are… • Low-level types and interfaces • Still
under discussion
Exploring HTTP APIs
https://github.com/swift-server/http/blob/develop/API.md
Types in HTTP APIs • HTTPRequest • HTTPResponse • HTTPResponseWriter
• HTTPBodyHandler • HTTPBodyProcessing • HTTPBodyChunk • etc…
Interfaces in HTTP APIs typealias WebApp = (HTTPRequest, HTTPResponseWriter) ->
HTTPBodyProcessing
Interfaces in HTTP APIs enum HTTPBodyProcessing { case discardBody case
processBody(handler: HTTPBodyHandler) } typealias HTTPBodyHandler = (HTTPBodyChunk, inout Bool) -> Void
Sample App let myApp = { (req: HTTPRequest, res: HTTPResponseWriter
) -> HTTPBodyProcessing in res.writeResponse(HTTPResponse( httpVersion: req.httpVersion, status: .ok, transferEncoding: .chunked, headers: HTTPHeaders([("Content-Type", "text/plain")]) )) return .processBody { (chunk, stop) in switch chunk { case .chunk(let data, let finishedProcessing): res.writeBody(data: data) { _ in finishedProcessing() } case .end: res.done() default: stop = true res.abort() } } }
Implementations
BlueSocketHTTP • Prototype implementation of HTTP APIs • Based on
IBM BlueSocket https://github.com/swift-server/http/tree/develop/Sources/BlueSocketHTTP
Deploying with BlueSocketHTTP import HTTP import BlueSocketHTTP let server =
BlueSocketSimpleServer() do { try server.start(port: 8080, webapp: myApp) }
Summary
Swift HTTP APIs are… • Low-level types and functions •
for handling/responding to requests • Unstable, but prototype implementations are available • You can try with BlueSocketHTTP
Happy Server-Side Swift