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
Perfect framework
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Johnlin
February 02, 2016
Programming
140
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Perfect framework
讓你在後端也能使用 Swift
Johnlin
February 02, 2016
More Decks by Johnlin
See All by Johnlin
用 MLIR 實作 一個 Ruby IR (intermediate representation)
johnlinvc
0
390
Unearth Ruby builtin Gems 發掘 Ruby 的內建 Gems
johnlinvc
0
490
Ruby 型別檢查工具簡介
johnlinvc
0
700
Swift Actor 實作探索
johnlinvc
0
230
用 mruby 來寫跨平台工具
johnlinvc
0
150
Actor model 簡介
johnlinvc
0
280
一起玩 Helm 3
johnlinvc
1
200
為什麼 App 卡卡的
johnlinvc
2
1.4k
如何使用 byebug 來除錯 Ruby 程式
johnlinvc
0
300
Other Decks in Programming
See All in Programming
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
1k
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
220
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
210
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
170
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
160
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2k
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
630
パスワード再設定メールのURLについて知っておこう
uyuki234
0
160
Featured
See All Featured
Tell your own story through comics
letsgokoyo
1
1.1k
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
Thoughts on Productivity
jonyablonski
76
5.4k
Designing for Timeless Needs
cassininazir
1
530
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
870
Testing 201, or: Great Expectations
jmmastey
46
8.3k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
320
Transcript
Perfect framework John Lin (@johnlinvc)
Perfect framework 由PerfectlySoft 開發的 swift web framework https://github.com/PerfectlySoft/Perfect
特色 • 獨立HTTP server 與 Apache module • Request Router
• 支援 Mustache Template Engine • 資料庫連接器,支援MySQL, PostgreSQL, SQLite, MongoDB
Perfect server 包含3個不同的版本 • Standalone: 可以從CLI 直接執行 • Standalone Mac
App: Mac 的GUI HTTP server • mod_perfect: Apache 2.4 的 FastCGI module
運作原理 1. 自動載入在./PerfectLibraries 裡的任何 .framework 2. 執行module 中的 PerfectServerInit() 來註冊Route
和 template 3. 按照route 或 ./webroot 資料夾中的template 來執行對應的handler
使用方法 1. 下載source 2. 安裝Xcode template 3. 開新workspace 4. 使用template
開新專案 5. 匯入http server 與 Library 6. 設定excutable 7. 開始寫web API
下載Source git clone https://github.com/PerfectlySoft/Perfect.git
安裝 Perfect xcode 範本 mkdir -p ~/Library/Developer/Xcode/Templates/Project\ Templates cp Extras/Xcode
Templates/Perfect/Perfect Server Framework.xctemplate ~/Library/Developer/Xcode/Templates/Project\ Templates/
使用Template 開新專案
專案內容 • PerfectHandler.swift : 主要程式碼 • index.mustache : mustache template
匯入server 與 library 使用workspace 的 add file 功能把 PerfectServer/PerfectServer.xcodeproj 與
PerfectLib/PerfectLib.xcodeproj 都加入workspace中, 再把Perfect link 加進 Link Binary With Libraries清單中
設定Excutable
實作HTTP API Perfect 提供兩種API實作方法,page based 和 request based。 page based:
使用mustache template, 在template 中指定handler request based: 使用Router來指定handler 兩者目前無法混用
註冊page handler
在mustache template中指定handler
實作PageHandler
取得http request param
註冊Request Handler
實作Request handler
下回預告 PerfectObject 讓你在server和client 之間共用Data Class,全自動呼叫HTTP API。
Q&A