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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
340
Unearth Ruby builtin Gems 發掘 Ruby 的內建 Gems
johnlinvc
0
420
Ruby 型別檢查工具簡介
johnlinvc
0
640
Swift Actor 實作探索
johnlinvc
0
210
用 mruby 來寫跨平台工具
johnlinvc
0
130
Actor model 簡介
johnlinvc
0
250
一起玩 Helm 3
johnlinvc
1
170
為什麼 App 卡卡的
johnlinvc
2
1.3k
如何使用 byebug 來除錯 Ruby 程式
johnlinvc
0
280
Other Decks in Programming
See All in Programming
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
170
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
0
170
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
260
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
4
2.8k
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
320
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
320
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
470
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
120
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
230
アクセシビリティから考える情報設計
high_g_engineer
0
380
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
200
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
390
Featured
See All Featured
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
420
WCS-LA-2024
lcolladotor
0
830
Odyssey Design
rkendrick25
PRO
2
810
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
570
Designing for Performance
lara
611
70k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Claude Code のすすめ
schroneko
67
230k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
280
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
500
Darren the Foodie - Storyboard
khoart
PRO
4
3.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
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