mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	go1.16 (#14783)
This commit is contained in:
		
							
								
								
									
										19
									
								
								vendor/github.com/go-chi/chi/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/go-chi/chi/CHANGELOG.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,5 +1,24 @@ | ||||
| # Changelog | ||||
|  | ||||
| ## v1.5.4 (2021-02-27) | ||||
|  | ||||
| - Undo prior retraction in v1.5.3 as we prepare for v5.0.0 release | ||||
| - History of changes: see https://github.com/go-chi/chi/compare/v1.5.3...v1.5.4 | ||||
|  | ||||
|  | ||||
| ## v1.5.3 (2021-02-21) | ||||
|  | ||||
| - Update go.mod to go 1.16 with new retract directive marking all versions without prior go.mod support | ||||
| - History of changes: see https://github.com/go-chi/chi/compare/v1.5.2...v1.5.3 | ||||
|  | ||||
|  | ||||
| ## v1.5.2 (2021-02-10) | ||||
|  | ||||
| - Reverting allocation optimization as a precaution as go test -race fails. | ||||
| - Minor improvements, see history below | ||||
| - History of changes: see https://github.com/go-chi/chi/compare/v1.5.1...v1.5.2 | ||||
|  | ||||
|  | ||||
| ## v1.5.1 (2020-12-06) | ||||
|  | ||||
| - Performance improvement: removing 1 allocation by foregoing context.WithValue, thank you @bouk for | ||||
|   | ||||
							
								
								
									
										14
									
								
								vendor/github.com/go-chi/chi/Makefile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								vendor/github.com/go-chi/chi/Makefile
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| all: | ||||
| 	@echo "**********************************************************" | ||||
| 	@echo "**                    chi build tool                    **" | ||||
| 	@echo "**********************************************************" | ||||
|  | ||||
|  | ||||
| test: | ||||
| 	go clean -testcache && $(MAKE) test-router && $(MAKE) test-middleware | ||||
|  | ||||
| test-router: | ||||
| 	go test -race -v . | ||||
|  | ||||
| test-middleware: | ||||
| 	go test -race -v ./middleware | ||||
							
								
								
									
										27
									
								
								vendor/github.com/go-chi/chi/context.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								vendor/github.com/go-chi/chi/context.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -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. | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/go-chi/chi/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/go-chi/chi/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,3 +1,3 @@ | ||||
| module github.com/go-chi/chi | ||||
|  | ||||
| go 1.15 | ||||
| go 1.16 | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/go-chi/chi/middleware/profiler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/go-chi/chi/middleware/profiler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -23,10 +23,10 @@ func Profiler() http.Handler { | ||||
| 	r.Use(NoCache) | ||||
|  | ||||
| 	r.Get("/", func(w http.ResponseWriter, r *http.Request) { | ||||
| 		http.Redirect(w, r, r.RequestURI+"/pprof/", 301) | ||||
| 		http.Redirect(w, r, r.RequestURI+"/pprof/", http.StatusMovedPermanently) | ||||
| 	}) | ||||
| 	r.HandleFunc("/pprof", func(w http.ResponseWriter, r *http.Request) { | ||||
| 		http.Redirect(w, r, r.RequestURI+"/", 301) | ||||
| 		http.Redirect(w, r, r.RequestURI+"/", http.StatusMovedPermanently) | ||||
| 	}) | ||||
|  | ||||
| 	r.HandleFunc("/pprof/*", pprof.Index) | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/go-chi/chi/middleware/route_headers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/go-chi/chi/middleware/route_headers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -50,7 +50,7 @@ func RouteHeaders() HeaderRouter { | ||||
|  | ||||
| type HeaderRouter map[string][]HeaderRoute | ||||
|  | ||||
| func (hr HeaderRouter) Route(header string, match string, middlewareHandler func(next http.Handler) http.Handler) HeaderRouter { | ||||
| func (hr HeaderRouter) Route(header, match string, middlewareHandler func(next http.Handler) http.Handler) HeaderRouter { | ||||
| 	header = strings.ToLower(header) | ||||
| 	k := hr[header] | ||||
| 	if k == nil { | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/go-chi/chi/middleware/strip.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/go-chi/chi/middleware/strip.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -52,8 +52,8 @@ func RedirectSlashes(next http.Handler) http.Handler { | ||||
| 			} else { | ||||
| 				path = path[:len(path)-1] | ||||
| 			} | ||||
| 			redirectUrl := fmt.Sprintf("//%s%s", r.Host, path) | ||||
| 			http.Redirect(w, r, redirectUrl, 301) | ||||
| 			redirectURL := fmt.Sprintf("//%s%s", r.Host, path) | ||||
| 			http.Redirect(w, r, redirectURL, 301) | ||||
| 			return | ||||
| 		} | ||||
| 		next.ServeHTTP(w, r) | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/go-chi/chi/middleware/throttle.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/go-chi/chi/middleware/throttle.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -35,7 +35,7 @@ func Throttle(limit int) func(http.Handler) http.Handler { | ||||
| // ThrottleBacklog is a middleware that limits number of currently processed | ||||
| // requests at a time and provides a backlog for holding a finite number of | ||||
| // pending requests. | ||||
| func ThrottleBacklog(limit int, backlogLimit int, backlogTimeout time.Duration) func(http.Handler) http.Handler { | ||||
| func ThrottleBacklog(limit, backlogLimit int, backlogTimeout time.Duration) func(http.Handler) http.Handler { | ||||
| 	return ThrottleWithOpts(ThrottleOpts{Limit: limit, BacklogLimit: backlogLimit, BacklogTimeout: backlogTimeout}) | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/go-chi/chi/middleware/value.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/go-chi/chi/middleware/value.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -6,7 +6,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| // WithValue is a middleware that sets a given key/value in a context chain. | ||||
| func WithValue(key interface{}, val interface{}) func(next http.Handler) http.Handler { | ||||
| func WithValue(key, val interface{}) func(next http.Handler) http.Handler { | ||||
| 	return func(next http.Handler) http.Handler { | ||||
| 		fn := func(w http.ResponseWriter, r *http.Request) { | ||||
| 			r = r.WithContext(context.WithValue(r.Context(), key, val)) | ||||
|   | ||||
							
								
								
									
										29
									
								
								vendor/github.com/go-chi/chi/middleware/wrap_writer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								vendor/github.com/go-chi/chi/middleware/wrap_writer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,19 +19,16 @@ func NewWrapResponseWriter(w http.ResponseWriter, protoMajor int) WrapResponseWr | ||||
|  | ||||
| 	if protoMajor == 2 { | ||||
| 		_, ps := w.(http.Pusher) | ||||
| 		if fl && ps { | ||||
| 		if fl || ps { | ||||
| 			return &http2FancyWriter{bw} | ||||
| 		} | ||||
| 	} else { | ||||
| 		_, hj := w.(http.Hijacker) | ||||
| 		_, rf := w.(io.ReaderFrom) | ||||
| 		if fl && hj && rf { | ||||
| 		if fl || hj || rf { | ||||
| 			return &httpFancyWriter{bw} | ||||
| 		} | ||||
| 	} | ||||
| 	if fl { | ||||
| 		return &flushWriter{bw} | ||||
| 	} | ||||
|  | ||||
| 	return &bw | ||||
| } | ||||
| @@ -110,18 +107,6 @@ func (b *basicWriter) Unwrap() http.ResponseWriter { | ||||
| 	return b.ResponseWriter | ||||
| } | ||||
|  | ||||
| type flushWriter struct { | ||||
| 	basicWriter | ||||
| } | ||||
|  | ||||
| func (f *flushWriter) Flush() { | ||||
| 	f.wroteHeader = true | ||||
| 	fl := f.basicWriter.ResponseWriter.(http.Flusher) | ||||
| 	fl.Flush() | ||||
| } | ||||
|  | ||||
| var _ http.Flusher = &flushWriter{} | ||||
|  | ||||
| // httpFancyWriter is a HTTP writer that additionally satisfies | ||||
| // http.Flusher, http.Hijacker, and io.ReaderFrom. It exists for the common case | ||||
| // of wrapping the http.ResponseWriter that package http gives you, in order to | ||||
| @@ -141,10 +126,6 @@ func (f *httpFancyWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { | ||||
| 	return hj.Hijack() | ||||
| } | ||||
|  | ||||
| func (f *http2FancyWriter) Push(target string, opts *http.PushOptions) error { | ||||
| 	return f.basicWriter.ResponseWriter.(http.Pusher).Push(target, opts) | ||||
| } | ||||
|  | ||||
| func (f *httpFancyWriter) ReadFrom(r io.Reader) (int64, error) { | ||||
| 	if f.basicWriter.tee != nil { | ||||
| 		n, err := io.Copy(&f.basicWriter, r) | ||||
| @@ -160,7 +141,6 @@ func (f *httpFancyWriter) ReadFrom(r io.Reader) (int64, error) { | ||||
|  | ||||
| var _ http.Flusher = &httpFancyWriter{} | ||||
| var _ http.Hijacker = &httpFancyWriter{} | ||||
| var _ http.Pusher = &http2FancyWriter{} | ||||
| var _ io.ReaderFrom = &httpFancyWriter{} | ||||
|  | ||||
| // http2FancyWriter is a HTTP2 writer that additionally satisfies | ||||
| @@ -177,4 +157,9 @@ func (f *http2FancyWriter) Flush() { | ||||
| 	fl.Flush() | ||||
| } | ||||
|  | ||||
| func (f *http2FancyWriter) Push(target string, opts *http.PushOptions) error { | ||||
| 	return f.basicWriter.ResponseWriter.(http.Pusher).Push(target, opts) | ||||
| } | ||||
|  | ||||
| var _ http.Flusher = &http2FancyWriter{} | ||||
| var _ http.Pusher = &http2FancyWriter{} | ||||
|   | ||||
							
								
								
									
										19
									
								
								vendor/github.com/go-chi/chi/mux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/go-chi/chi/mux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| package chi | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| 	"strings" | ||||
| @@ -79,8 +80,8 @@ func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||||
| 	rctx.Routes = mx | ||||
| 	rctx.parentCtx = r.Context() | ||||
|  | ||||
| 	// NOTE: r.WithContext() causes 2 allocations | ||||
| 	r = r.WithContext((*directContext)(rctx)) | ||||
| 	// NOTE: r.WithContext() causes 2 allocations and context.WithValue() causes 1 allocation | ||||
| 	r = r.WithContext(context.WithValue(r.Context(), RouteCtxKey, rctx)) | ||||
|  | ||||
| 	// Serve the request and once its done, put the request context back in the sync pool | ||||
| 	mx.handler.ServeHTTP(w, r) | ||||
| @@ -187,17 +188,16 @@ func (mx *Mux) Trace(pattern string, handlerFn http.HandlerFunc) { | ||||
| func (mx *Mux) NotFound(handlerFn http.HandlerFunc) { | ||||
| 	// Build NotFound handler chain | ||||
| 	m := mx | ||||
| 	hFn := handlerFn | ||||
| 	h := Chain(mx.middlewares...).HandlerFunc(handlerFn).ServeHTTP | ||||
| 	if mx.inline && mx.parent != nil { | ||||
| 		m = mx.parent | ||||
| 		hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP | ||||
| 	} | ||||
|  | ||||
| 	// Update the notFoundHandler from this point forward | ||||
| 	m.notFoundHandler = hFn | ||||
| 	m.notFoundHandler = h | ||||
| 	m.updateSubRoutes(func(subMux *Mux) { | ||||
| 		if subMux.notFoundHandler == nil { | ||||
| 			subMux.NotFound(hFn) | ||||
| 			subMux.NotFound(h) | ||||
| 		} | ||||
| 	}) | ||||
| } | ||||
| @@ -207,17 +207,16 @@ func (mx *Mux) NotFound(handlerFn http.HandlerFunc) { | ||||
| func (mx *Mux) MethodNotAllowed(handlerFn http.HandlerFunc) { | ||||
| 	// Build MethodNotAllowed handler chain | ||||
| 	m := mx | ||||
| 	hFn := handlerFn | ||||
| 	h := Chain(mx.middlewares...).HandlerFunc(handlerFn).ServeHTTP | ||||
| 	if mx.inline && mx.parent != nil { | ||||
| 		m = mx.parent | ||||
| 		hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP | ||||
| 	} | ||||
|  | ||||
| 	// Update the methodNotAllowedHandler from this point forward | ||||
| 	m.methodNotAllowedHandler = hFn | ||||
| 	m.methodNotAllowedHandler = h | ||||
| 	m.updateSubRoutes(func(subMux *Mux) { | ||||
| 		if subMux.methodNotAllowedHandler == nil { | ||||
| 			subMux.MethodNotAllowed(hFn) | ||||
| 			subMux.MethodNotAllowed(h) | ||||
| 		} | ||||
| 	}) | ||||
| } | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/github.com/go-chi/chi/tree.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/go-chi/chi/tree.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -6,7 +6,6 @@ package chi | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"math" | ||||
| 	"net/http" | ||||
| 	"regexp" | ||||
| 	"sort" | ||||
| @@ -55,10 +54,10 @@ func RegisterMethod(method string) { | ||||
| 		return | ||||
| 	} | ||||
| 	n := len(methodMap) | ||||
| 	if n > strconv.IntSize { | ||||
| 	if n > strconv.IntSize-2 { | ||||
| 		panic(fmt.Sprintf("chi: max number of methods reached (%d)", strconv.IntSize)) | ||||
| 	} | ||||
| 	mt := methodTyp(math.Exp2(float64(n))) | ||||
| 	mt := methodTyp(2 << n) | ||||
| 	methodMap[method] = mt | ||||
| 	mALL |= mt | ||||
| } | ||||
| @@ -430,6 +429,8 @@ func (n *node) findRoute(rctx *Context, method methodTyp, path string) *node { | ||||
| 					} else { | ||||
| 						continue | ||||
| 					} | ||||
| 				} else if ntyp == ntRegexp && p == 0 { | ||||
| 					continue | ||||
| 				} | ||||
|  | ||||
| 				if ntyp == ntRegexp && xn.rex != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user