Update README.md
This commit is contained in:
@@ -52,22 +52,22 @@ r := sux.New()
|
||||
// Named parameters
|
||||
r.GET("/users/:id", func(w http.ResponseWriter, r *http.Request) {
|
||||
params := sux.ParamsFromContext(r)
|
||||
id := params["id"]
|
||||
id := params.Get("id")
|
||||
io.WriteString(w, "User ID: "+id)
|
||||
})
|
||||
|
||||
// Wildcard parameters (captures rest of path)
|
||||
r.GET("/files/*path", func(w http.ResponseWriter, r *http.Request) {
|
||||
params := sux.ParamsFromContext(r)
|
||||
path := params["path"]
|
||||
path := params.Get("path")
|
||||
io.WriteString(w, "File path: "+path)
|
||||
})
|
||||
|
||||
// Multiple parameters
|
||||
r.GET("/users/:userId/posts/:postId", func(w http.ResponseWriter, r *http.Request) {
|
||||
params := sux.ParamsFromContext(r)
|
||||
userId := params["userId"]
|
||||
postId := params["postId"]
|
||||
userId := params.Get("userId")
|
||||
postId := params.Get("postId")
|
||||
io.WriteString(w, "User "+userId+", Post "+postId)
|
||||
})
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user