gorilla / pat Goto Github PK
View Code? Open in Web Editor NEWPackage gorilla/pat is a pretty simple HTTP router for Go.
Home Page: https://gorilla.github.io
License: BSD 3-Clause "New" or "Revised" License
Package gorilla/pat is a pretty simple HTTP router for Go.
Home Page: https://gorilla.github.io
License: BSD 3-Clause "New" or "Revised" License
Hi,
I use a mux.Router to handle top level path handling in my app,
and I'd like to use pat.Router for second-level path handling.
So I'd like to get a pat.Router as subrouter of a mux.Router.
Something like :
r := mux.NewRouter()
articles.Register(r.PathPrefix("/articles").Subrouter())
And in articles package:
func Register(r *pat.Router) {
r.Get("/{id}", read)
}
Currently, gorilla/pat
relies on gorilla/context
, but since Go 1.7 that is actually not needed. I would like to propose that for Go 1.7+, gorilla/pat
should use the native context
package, just like gorilla/mux
did: https://github.com/gorilla/mux/blob/master/context_native.go
The problem is that gorilla/pat
would rely only on the contextClear
func, that currently is a no-op on the native implementation. We could implement contextClear
to set the request context as a fresh context.Backgroun()
.
Would a PR for this be acceptable?
would be nice if Add() accepts a http.HandlerFunc too ... if this was not intentional
We should use the same TravisCI config as mux: https://github.com/gorilla/mux/blob/master/.travis.yml as pat depends on mux.
In REST-like API, PUT should only be used if you're replacing a resource in it's entirety.
According to RFC 5789:
Several applications extending the Hypertext Transfer Protocol (HTTP) require a feature to do partial resource modification. The existing HTTP PUT method only allows a complete replacement of a document. This proposal adds a new HTTP method, PATCH, to modify an existing HTTP resource.
The current tag is not following the semver principle. It would be great to tag it 1.0.0
for golang modules usage.
The README could use some love for users not coming via http://www.gorillatoolkit.org/pkg/pat (or at least link to that).
On initial inspection I don't see an elegant way to use pat with a path-prefixed Subrouter. Do I ditch pat and just go straight mux at this point?
When handling requests the KeepContext
field is not respected (unlike in the mux
package) and context
is .Clear(req)
'ed on every request.
How would define a route for /api/things?a=1
router.Get("/api/things?a={id}", getAllTheThings)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.