mirror of
https://github.com/restic/rest-server.git
synced 2025-12-07 09:36:13 -08:00
Vendor dependencies
This commit is contained in:
committed by
Zlatko Čalušić
parent
2f0a16d8b7
commit
6054876201
33
vendor/goji.io/router_simple.go
generated
vendored
Normal file
33
vendor/goji.io/router_simple.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// +build goji_router_simple
|
||||
|
||||
package goji
|
||||
|
||||
import "net/http"
|
||||
|
||||
/*
|
||||
This is the simplest correct router implementation for Goji.
|
||||
*/
|
||||
|
||||
type router []route
|
||||
|
||||
type route struct {
|
||||
Pattern
|
||||
http.Handler
|
||||
}
|
||||
|
||||
func (rt *router) add(p Pattern, h http.Handler) {
|
||||
*rt = append(*rt, route{p, h})
|
||||
}
|
||||
|
||||
func (rt *router) route(r *http.Request) *http.Request {
|
||||
for _, route := range *rt {
|
||||
if r2 := route.Match(r); r2 != nil {
|
||||
return r2.WithContext(&match{
|
||||
Context: r2.Context(),
|
||||
p: route.Pattern,
|
||||
h: route.Handler,
|
||||
})
|
||||
}
|
||||
}
|
||||
return r.WithContext(&match{Context: r.Context()})
|
||||
}
|
||||
Reference in New Issue
Block a user