File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 11##Pure
22<img align =" right " src =" https://raw.githubusercontent.com/go-playground/pure/master/logo.png " >
3- ![ Project status] ( https://img.shields.io/badge/version-3.0.0 -green.svg )
3+ ![ Project status] ( https://img.shields.io/badge/version-3.0.1 -green.svg )
44[ ![ Build Status] ( https://semaphoreci.com/api/v1/joeybloggs/pure/branches/master/badge.svg )] ( https://semaphoreci.com/joeybloggs/pure )
55[ ![ Coverage Status] ( https://coveralls.io/repos/github/go-playground/pure/badge.svg?branch=master )] ( https://coveralls.io/github/go-playground/pure?branch=master )
66[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/go-playground/pure )] ( https://goreportcard.com/report/github.com/go-playground/pure )
@@ -76,10 +76,9 @@ l.Get("/user/:id", UserHandler)
7676
7777// extract params like so
7878rv := pure.ReqestVars (r) // done this way so only have to extract from context once, read above
79- params := rv.Params () or params := pure.ReqestVars (r).Params ()
80- params.Get (paramname)
79+ rv.URLParam (paramname)
8180
82- // serve css, js etc.. pure.RequestVars(r).Params().Get (pure.WildcardParam) will return the remaining path if
81+ // serve css, js etc.. pure.RequestVars(r).URLParam (pure.WildcardParam) will return the remaining path if
8382// you need to use it in a custom handler...
8483l.Get (" /static/*" , http.FileServer (http.Dir (" static/" )))
8584
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "net/http"
5+
6+ "github.com/go-playground/pure"
7+ mw "github.com/go-playground/pure/examples/middleware/logging-recovery"
8+ )
9+
10+ func main () {
11+
12+ p := pure .New ()
13+ p .Use (mw .LoggingAndRecovery (true ))
14+
15+ p .Get ("/user/:id" , user )
16+
17+ http .ListenAndServe (":3007" , p .Serve ())
18+ }
19+
20+ func user (w http.ResponseWriter , r * http.Request ) {
21+ rv := pure .RequestVars (r )
22+
23+ w .Write ([]byte ("USER_ID:" + rv .URLParam ("id" )))
24+ }
You can’t perform that action at this time.
0 commit comments