jollen / blog

Jollen's Blog
http://www.jollen.org/blog
66 stars 4 forks source link

學習 Unikernel 與 runtimejs (Part 3)-如何打造一個 Fast URL Router #14

Open jollen opened 8 years ago

jollen commented 8 years ago

URL Routing 是 web application framework 很重要的 component,在這次的 simple-iot-runtime 練習專案中,將不使用 Express 或是 Express Router。遵循 build from scratch 的原則,以及「重造車輪」,是這個功課的指導原則。

URL Router 的做法有好幾種,第一種是 simple and stupid 的方式:字串比對,第二種是用 Ternary Search Tree[1] 的資料結構來進行搜尋。Ternary Search Tree 的做法,時間複雜度較低,理論上是實作 Fast URL Router[2][3] 的好選項。

參考資源