pip compatible server to serve Python packages out of GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
563 B

package middleware
import (
"github.com/zenazn/goji/web"
"net/http"
)
// URLQueryKey is the context key for the URL Query
const URLQueryKey string = "urlquery"
// URLQuery is a middleware to parse the URL Query parameters just once,
// and store the resulting url.Values in the context.
func URLQuery(c *web.C, h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
if c.Env == nil {
c.Env = make(map[interface{}]interface{})
}
c.Env[URLQueryKey] = r.URL.Query()
h.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
}