1
0
Fork 0
forked from forgejo/forgejo
This commit is contained in:
techknowlogick 2021-02-28 18:08:33 -05:00 committed by GitHub
parent 030646eea4
commit 47f6a4ec3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
947 changed files with 26119 additions and 7062 deletions

View file

@ -4,7 +4,6 @@ import (
"context"
"net/http"
"strings"
"time"
)
// URLParam returns the url parameter from a http.Request object.
@ -146,32 +145,6 @@ func (s *RouteParams) Add(key, value string) {
s.Values = append(s.Values, value)
}
// directContext provides direct access to the routing *Context object,
// while implementing the context.Context interface, thereby allowing
// us to saving 1 allocation during routing.
type directContext Context
var _ context.Context = (*directContext)(nil)
func (d *directContext) Deadline() (deadline time.Time, ok bool) {
return d.parentCtx.Deadline()
}
func (d *directContext) Done() <-chan struct{} {
return d.parentCtx.Done()
}
func (d *directContext) Err() error {
return d.parentCtx.Err()
}
func (d *directContext) Value(key interface{}) interface{} {
if key == RouteCtxKey {
return (*Context)(d)
}
return d.parentCtx.Value(key)
}
// contextKey is a value for use with context.WithValue. It's used as
// a pointer so it fits in an interface{} without allocation. This technique
// for defining context keys was copied from Go 1.7's new use of context in net/http.