用于Go非常簡單和快速HTTP路由器:Zeus

jopen 10年前發布 | 29K 次閱讀 Zeus Google Go/Golang開發

Zeus是一個用于Go應用非常簡單和快速的HTTP路由器。用法:

package main

import ( "fmt" "github.com/daryl/zeus" "net/http" )

func main() { mux := zeus.New() // Supports named parameters mux.GET("/users/:id", showUser) // Custom 404 handler mux.NotFound = notFound // Listen and serve mux.Listen(":4545") }

func showUser(w http.ResponseWriter, r *http.Request) { // Extract parameter value id := r.URL.Query().Get("id")

fmt.Fprintf(w, "User ID: %s", id)

}

func notFound(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Nothing to see here") }</pre>

項目主頁:http://www.baiduhome.net/lib/view/home/1416205365695

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!