用于Go非常简单和快速HTTP路由器:Zeus

jopen 10年前

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")  }

项目主页:http://www.open-open.com/lib/view/home/1416205365695