Commit 1c05ab46 by lancet

more to basic routing

parent 0e26ff4e
No preview for this file type
......@@ -20,6 +20,13 @@ func getValue(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, resp)
}
func setValue(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
resp := fmt.Sprintf("Set ID: %s\n", id)
fmt.Fprint(w, resp)
}
func delValue(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
......@@ -40,6 +47,8 @@ func main() {
router := mux.NewRouter()
routing := []Route{
{"/storage/{id}", []string{"GET"}, getValue},
{"/storage/{id}", []string{"PUT", "POST"}, setValue},
{"/storage/{id}", []string{"DELETE"}, delValue},
}
initRouter(router, routing)
http.Handle("/", router)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment