mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 03:40:01 -06:00
build(deps): bump github.com/go-chi/chi/v5 from 5.0.10 to 5.0.11
Bumps [github.com/go-chi/chi/v5](https://github.com/go-chi/chi) from 5.0.10 to 5.0.11. - [Release notes](https://github.com/go-chi/chi/releases) - [Changelog](https://github.com/go-chi/chi/blob/master/CHANGELOG.md) - [Commits](https://github.com/go-chi/chi/compare/v5.0.10...v5.0.11) --- updated-dependencies: - dependency-name: github.com/go-chi/chi/v5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
dc2f151eb4
commit
ab57f985cc
2
go.mod
2
go.mod
@@ -20,7 +20,7 @@ require (
|
||||
github.com/egirna/icap-client v0.1.1
|
||||
github.com/gabriel-vasile/mimetype v1.4.3
|
||||
github.com/ggwhite/go-masker v1.1.0
|
||||
github.com/go-chi/chi/v5 v5.0.10
|
||||
github.com/go-chi/chi/v5 v5.0.11
|
||||
github.com/go-chi/cors v1.2.1
|
||||
github.com/go-chi/render v1.0.3
|
||||
github.com/go-ldap/ldap/v3 v3.4.6
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1138,8 +1138,8 @@ github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||
github.com/go-chi/chi/v5 v5.0.8/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
|
||||
github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA=
|
||||
github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
|
||||
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
|
||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
|
||||
9
vendor/github.com/go-chi/chi/v5/CHANGELOG.md
generated
vendored
9
vendor/github.com/go-chi/chi/v5/CHANGELOG.md
generated
vendored
@@ -1,9 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
## v5.0.11 (2023-12-19)
|
||||
|
||||
- History of changes: see https://github.com/go-chi/chi/compare/v5.0.10...v5.0.11
|
||||
|
||||
|
||||
## v5.0.10 (2023-07-13)
|
||||
|
||||
- Fixed small edge case in tests of v5.0.9 for older Go versions
|
||||
- History of changes: see https://github.com/go-chi/chi/compare/v5.0.8...v5.0.10
|
||||
- History of changes: see https://github.com/go-chi/chi/compare/v5.0.9...v5.0.10
|
||||
|
||||
|
||||
## v5.0.9 (2023-07-13)
|
||||
@@ -306,7 +311,7 @@ Cheers all, happy coding!
|
||||
request-scoped values. We're very excited about the new context addition and are proud to
|
||||
introduce chi v2, a minimal and powerful routing package for building large HTTP services,
|
||||
with zero external dependencies. Chi focuses on idiomatic design and encourages the use of
|
||||
stdlib HTTP handlers and middlwares.
|
||||
stdlib HTTP handlers and middlewares.
|
||||
- chi v2 deprecates its `chi.Handler` interface and requires `http.Handler` or `http.HandlerFunc`
|
||||
- chi v2 stores URL routing parameters and patterns in the standard request context: `r.Context()`
|
||||
- chi v2 lower-level routing context is accessible by `chi.RouteContext(r.Context()) *chi.Context`,
|
||||
|
||||
2
vendor/github.com/go-chi/chi/v5/README.md
generated
vendored
2
vendor/github.com/go-chi/chi/v5/README.md
generated
vendored
@@ -494,7 +494,7 @@ Copyright (c) 2015-present [Peter Kieltyka](https://github.com/pkieltyka)
|
||||
|
||||
Licensed under [MIT License](./LICENSE)
|
||||
|
||||
[GoDoc]: https://pkg.go.dev/github.com/go-chi/chi?tab=versions
|
||||
[GoDoc]: https://pkg.go.dev/github.com/go-chi/chi/v5
|
||||
[GoDoc Widget]: https://godoc.org/github.com/go-chi/chi?status.svg
|
||||
[Travis]: https://travis-ci.org/go-chi/chi
|
||||
[Travis Widget]: https://travis-ci.org/go-chi/chi.svg?branch=master
|
||||
|
||||
5
vendor/github.com/go-chi/chi/v5/SECURITY.md
generated
vendored
Normal file
5
vendor/github.com/go-chi/chi/v5/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Reporting Security Issues
|
||||
|
||||
We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
|
||||
|
||||
To report a security issue, please use the GitHub Security Advisory ["Report a Vulnerability"](https://github.com/go-chi/chi/security/advisories/new) tab.
|
||||
23
vendor/github.com/go-chi/chi/v5/context.go
generated
vendored
23
vendor/github.com/go-chi/chi/v5/context.go
generated
vendored
@@ -60,7 +60,7 @@ type Context struct {
|
||||
URLParams RouteParams
|
||||
|
||||
// Route parameters matched for the current sub-router. It is
|
||||
// intentionally unexported so it cant be tampered.
|
||||
// intentionally unexported so it can't be tampered.
|
||||
routeParams RouteParams
|
||||
|
||||
// The endpoint routing pattern that matched the request URI path
|
||||
@@ -92,6 +92,7 @@ func (x *Context) Reset() {
|
||||
x.routeParams.Keys = x.routeParams.Keys[:0]
|
||||
x.routeParams.Values = x.routeParams.Values[:0]
|
||||
x.methodNotAllowed = false
|
||||
x.methodsAllowed = x.methodsAllowed[:0]
|
||||
x.parentCtx = nil
|
||||
}
|
||||
|
||||
@@ -113,18 +114,20 @@ func (x *Context) URLParam(key string) string {
|
||||
//
|
||||
// For example,
|
||||
//
|
||||
// func Instrument(next http.Handler) http.Handler {
|
||||
// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// next.ServeHTTP(w, r)
|
||||
// routePattern := chi.RouteContext(r.Context()).RoutePattern()
|
||||
// measure(w, r, routePattern)
|
||||
// })
|
||||
// }
|
||||
// func Instrument(next http.Handler) http.Handler {
|
||||
// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// next.ServeHTTP(w, r)
|
||||
// routePattern := chi.RouteContext(r.Context()).RoutePattern()
|
||||
// measure(w, r, routePattern)
|
||||
// })
|
||||
// }
|
||||
func (x *Context) RoutePattern() string {
|
||||
routePattern := strings.Join(x.RoutePatterns, "")
|
||||
routePattern = replaceWildcards(routePattern)
|
||||
routePattern = strings.TrimSuffix(routePattern, "//")
|
||||
routePattern = strings.TrimSuffix(routePattern, "/")
|
||||
if routePattern != "/" {
|
||||
routePattern = strings.TrimSuffix(routePattern, "//")
|
||||
routePattern = strings.TrimSuffix(routePattern, "/")
|
||||
}
|
||||
return routePattern
|
||||
}
|
||||
|
||||
|
||||
39
vendor/github.com/go-chi/chi/v5/middleware/compress.go
generated
vendored
39
vendor/github.com/go-chi/chi/v5/middleware/compress.go
generated
vendored
@@ -137,14 +137,14 @@ func NewCompressor(level int, types ...string) *Compressor {
|
||||
//
|
||||
// For example, add the Brotli algorithm:
|
||||
//
|
||||
// import brotli_enc "gopkg.in/kothar/brotli-go.v0/enc"
|
||||
// import brotli_enc "gopkg.in/kothar/brotli-go.v0/enc"
|
||||
//
|
||||
// compressor := middleware.NewCompressor(5, "text/html")
|
||||
// compressor.SetEncoder("br", func(w io.Writer, level int) io.Writer {
|
||||
// params := brotli_enc.NewBrotliParams()
|
||||
// params.SetQuality(level)
|
||||
// return brotli_enc.NewBrotliWriter(params, w)
|
||||
// })
|
||||
// compressor := middleware.NewCompressor(5, "text/html")
|
||||
// compressor.SetEncoder("br", func(w io.Writer, level int) io.Writer {
|
||||
// params := brotli_enc.NewBrotliParams()
|
||||
// params.SetQuality(level)
|
||||
// return brotli_enc.NewBrotliWriter(params, w)
|
||||
// })
|
||||
func (c *Compressor) SetEncoder(encoding string, fn EncoderFunc) {
|
||||
encoding = strings.ToLower(encoding)
|
||||
if encoding == "" {
|
||||
@@ -156,12 +156,8 @@ func (c *Compressor) SetEncoder(encoding string, fn EncoderFunc) {
|
||||
|
||||
// If we are adding a new encoder that is already registered, we have to
|
||||
// clear that one out first.
|
||||
if _, ok := c.pooledEncoders[encoding]; ok {
|
||||
delete(c.pooledEncoders, encoding)
|
||||
}
|
||||
if _, ok := c.encoders[encoding]; ok {
|
||||
delete(c.encoders, encoding)
|
||||
}
|
||||
delete(c.pooledEncoders, encoding)
|
||||
delete(c.encoders, encoding)
|
||||
|
||||
// If the encoder supports Resetting (IoReseterWriter), then it can be pooled.
|
||||
encoder := fn(ioutil.Discard, c.level)
|
||||
@@ -201,7 +197,7 @@ func (c *Compressor) Handler(next http.Handler) http.Handler {
|
||||
contentTypes: c.allowedTypes,
|
||||
contentWildcards: c.allowedWildcards,
|
||||
encoding: encoding,
|
||||
compressable: false, // determined in post-handler
|
||||
compressible: false, // determined in post-handler
|
||||
}
|
||||
if encoder != nil {
|
||||
cw.w = encoder
|
||||
@@ -275,10 +271,10 @@ type compressResponseWriter struct {
|
||||
contentWildcards map[string]struct{}
|
||||
encoding string
|
||||
wroteHeader bool
|
||||
compressable bool
|
||||
compressible bool
|
||||
}
|
||||
|
||||
func (cw *compressResponseWriter) isCompressable() bool {
|
||||
func (cw *compressResponseWriter) isCompressible() bool {
|
||||
// Parse the first part of the Content-Type response header.
|
||||
contentType := cw.Header().Get("Content-Type")
|
||||
if idx := strings.Index(contentType, ";"); idx >= 0 {
|
||||
@@ -310,13 +306,13 @@ func (cw *compressResponseWriter) WriteHeader(code int) {
|
||||
return
|
||||
}
|
||||
|
||||
if !cw.isCompressable() {
|
||||
cw.compressable = false
|
||||
if !cw.isCompressible() {
|
||||
cw.compressible = false
|
||||
return
|
||||
}
|
||||
|
||||
if cw.encoding != "" {
|
||||
cw.compressable = true
|
||||
cw.compressible = true
|
||||
cw.Header().Set("Content-Encoding", cw.encoding)
|
||||
cw.Header().Add("Vary", "Accept-Encoding")
|
||||
|
||||
@@ -334,11 +330,10 @@ func (cw *compressResponseWriter) Write(p []byte) (int, error) {
|
||||
}
|
||||
|
||||
func (cw *compressResponseWriter) writer() io.Writer {
|
||||
if cw.compressable {
|
||||
if cw.compressible {
|
||||
return cw.w
|
||||
} else {
|
||||
return cw.ResponseWriter
|
||||
}
|
||||
return cw.ResponseWriter
|
||||
}
|
||||
|
||||
type compressFlusher interface {
|
||||
|
||||
9
vendor/github.com/go-chi/chi/v5/middleware/logger.go
generated
vendored
9
vendor/github.com/go-chi/chi/v5/middleware/logger.go
generated
vendored
@@ -31,10 +31,11 @@ var (
|
||||
//
|
||||
// IMPORTANT NOTE: Logger should go before any other middleware that may change
|
||||
// the response, such as middleware.Recoverer. Example:
|
||||
// r := chi.NewRouter()
|
||||
// r.Use(middleware.Logger) // <--<< Logger should come before Recoverer
|
||||
// r.Use(middleware.Recoverer)
|
||||
// r.Get("/", handler)
|
||||
//
|
||||
// r := chi.NewRouter()
|
||||
// r.Use(middleware.Logger) // <--<< Logger should come before Recoverer
|
||||
// r.Use(middleware.Recoverer)
|
||||
// r.Get("/", handler)
|
||||
func Logger(next http.Handler) http.Handler {
|
||||
return DefaultLogger(next)
|
||||
}
|
||||
|
||||
9
vendor/github.com/go-chi/chi/v5/middleware/nocache.go
generated
vendored
9
vendor/github.com/go-chi/chi/v5/middleware/nocache.go
generated
vendored
@@ -32,10 +32,11 @@ var etagHeaders = []string{
|
||||
// a router (or subrouter) from being cached by an upstream proxy and/or client.
|
||||
//
|
||||
// As per http://wiki.nginx.org/HttpProxyModule - NoCache sets:
|
||||
// Expires: Thu, 01 Jan 1970 00:00:00 UTC
|
||||
// Cache-Control: no-cache, private, max-age=0
|
||||
// X-Accel-Expires: 0
|
||||
// Pragma: no-cache (for HTTP/1.0 proxies/clients)
|
||||
//
|
||||
// Expires: Thu, 01 Jan 1970 00:00:00 UTC
|
||||
// Cache-Control: no-cache, private, max-age=0
|
||||
// X-Accel-Expires: 0
|
||||
// Pragma: no-cache (for HTTP/1.0 proxies/clients)
|
||||
func NoCache(h http.Handler) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
|
||||
32
vendor/github.com/go-chi/chi/v5/middleware/profiler.go
generated
vendored
32
vendor/github.com/go-chi/chi/v5/middleware/profiler.go
generated
vendored
@@ -2,7 +2,6 @@ package middleware
|
||||
|
||||
import (
|
||||
"expvar"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
|
||||
@@ -11,13 +10,13 @@ import (
|
||||
|
||||
// Profiler is a convenient subrouter used for mounting net/http/pprof. ie.
|
||||
//
|
||||
// func MyService() http.Handler {
|
||||
// r := chi.NewRouter()
|
||||
// // ..middlewares
|
||||
// r.Mount("/debug", middleware.Profiler())
|
||||
// // ..routes
|
||||
// return r
|
||||
// }
|
||||
// func MyService() http.Handler {
|
||||
// r := chi.NewRouter()
|
||||
// // ..middlewares
|
||||
// r.Mount("/debug", middleware.Profiler())
|
||||
// // ..routes
|
||||
// return r
|
||||
// }
|
||||
func Profiler() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
r.Use(NoCache)
|
||||
@@ -34,7 +33,7 @@ func Profiler() http.Handler {
|
||||
r.HandleFunc("/pprof/profile", pprof.Profile)
|
||||
r.HandleFunc("/pprof/symbol", pprof.Symbol)
|
||||
r.HandleFunc("/pprof/trace", pprof.Trace)
|
||||
r.HandleFunc("/vars", expVars)
|
||||
r.Handle("/vars", expvar.Handler())
|
||||
|
||||
r.Handle("/pprof/goroutine", pprof.Handler("goroutine"))
|
||||
r.Handle("/pprof/threadcreate", pprof.Handler("threadcreate"))
|
||||
@@ -45,18 +44,3 @@ func Profiler() http.Handler {
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// Replicated from expvar.go as not public.
|
||||
func expVars(w http.ResponseWriter, r *http.Request) {
|
||||
first := true
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
fmt.Fprintf(w, "{\n")
|
||||
expvar.Do(func(kv expvar.KeyValue) {
|
||||
if !first {
|
||||
fmt.Fprintf(w, ",\n")
|
||||
}
|
||||
first = false
|
||||
fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value)
|
||||
})
|
||||
fmt.Fprintf(w, "\n}\n")
|
||||
}
|
||||
|
||||
15
vendor/github.com/go-chi/chi/v5/middleware/recoverer.go
generated
vendored
15
vendor/github.com/go-chi/chi/v5/middleware/recoverer.go
generated
vendored
@@ -113,15 +113,14 @@ func (s prettyStack) decorateLine(line string, useColor bool, num int) (string,
|
||||
line = strings.TrimSpace(line)
|
||||
if strings.HasPrefix(line, "\t") || strings.Contains(line, ".go:") {
|
||||
return s.decorateSourceLine(line, useColor, num)
|
||||
} else if strings.HasSuffix(line, ")") {
|
||||
return s.decorateFuncCallLine(line, useColor, num)
|
||||
} else {
|
||||
if strings.HasPrefix(line, "\t") {
|
||||
return strings.Replace(line, "\t", " ", 1), nil
|
||||
} else {
|
||||
return fmt.Sprintf(" %s\n", line), nil
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(line, ")") {
|
||||
return s.decorateFuncCallLine(line, useColor, num)
|
||||
}
|
||||
if strings.HasPrefix(line, "\t") {
|
||||
return strings.Replace(line, "\t", " ", 1), nil
|
||||
}
|
||||
return fmt.Sprintf(" %s\n", line), nil
|
||||
}
|
||||
|
||||
func (s prettyStack) decorateFuncCallLine(line string, useColor bool, num int) (string, error) {
|
||||
|
||||
57
vendor/github.com/go-chi/chi/v5/middleware/route_headers.go
generated
vendored
57
vendor/github.com/go-chi/chi/v5/middleware/route_headers.go
generated
vendored
@@ -11,39 +11,34 @@ import (
|
||||
// For example, lets say you'd like to setup multiple routers depending on the
|
||||
// request Host header, you could then do something as so:
|
||||
//
|
||||
// r := chi.NewRouter()
|
||||
// rSubdomain := chi.NewRouter()
|
||||
//
|
||||
// r.Use(middleware.RouteHeaders().
|
||||
// Route("Host", "example.com", middleware.New(r)).
|
||||
// Route("Host", "*.example.com", middleware.New(rSubdomain)).
|
||||
// Handler)
|
||||
//
|
||||
// r.Get("/", h)
|
||||
// rSubdomain.Get("/", h2)
|
||||
//
|
||||
// r := chi.NewRouter()
|
||||
// rSubdomain := chi.NewRouter()
|
||||
// r.Use(middleware.RouteHeaders().
|
||||
// Route("Host", "example.com", middleware.New(r)).
|
||||
// Route("Host", "*.example.com", middleware.New(rSubdomain)).
|
||||
// Handler)
|
||||
// r.Get("/", h)
|
||||
// rSubdomain.Get("/", h2)
|
||||
//
|
||||
// Another example, imagine you want to setup multiple CORS handlers, where for
|
||||
// your origin servers you allow authorized requests, but for third-party public
|
||||
// requests, authorization is disabled.
|
||||
//
|
||||
// r := chi.NewRouter()
|
||||
//
|
||||
// r.Use(middleware.RouteHeaders().
|
||||
// Route("Origin", "https://app.skyweaver.net", cors.Handler(cors.Options{
|
||||
// AllowedOrigins: []string{"https://api.skyweaver.net"},
|
||||
// AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
// AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
||||
// AllowCredentials: true, // <----------<<< allow credentials
|
||||
// })).
|
||||
// Route("Origin", "*", cors.Handler(cors.Options{
|
||||
// AllowedOrigins: []string{"*"},
|
||||
// AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
// AllowedHeaders: []string{"Accept", "Content-Type"},
|
||||
// AllowCredentials: false, // <----------<<< do not allow credentials
|
||||
// })).
|
||||
// Handler)
|
||||
//
|
||||
// r := chi.NewRouter()
|
||||
// r.Use(middleware.RouteHeaders().
|
||||
// Route("Origin", "https://app.skyweaver.net", cors.Handler(cors.Options{
|
||||
// AllowedOrigins: []string{"https://api.skyweaver.net"},
|
||||
// AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
// AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
||||
// AllowCredentials: true, // <----------<<< allow credentials
|
||||
// })).
|
||||
// Route("Origin", "*", cors.Handler(cors.Options{
|
||||
// AllowedOrigins: []string{"*"},
|
||||
// AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
// AllowedHeaders: []string{"Accept", "Content-Type"},
|
||||
// AllowCredentials: false, // <----------<<< do not allow credentials
|
||||
// })).
|
||||
// Handler)
|
||||
func RouteHeaders() HeaderRouter {
|
||||
return HeaderRouter{}
|
||||
}
|
||||
@@ -150,11 +145,7 @@ func NewPattern(value string) Pattern {
|
||||
|
||||
func (p Pattern) Match(v string) bool {
|
||||
if !p.wildcard {
|
||||
if p.prefix == v {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
return p.prefix == v
|
||||
}
|
||||
return len(v) >= len(p.prefix+p.suffix) && strings.HasPrefix(v, p.prefix) && strings.HasSuffix(v, p.suffix)
|
||||
}
|
||||
|
||||
25
vendor/github.com/go-chi/chi/v5/middleware/sunset.go
generated
vendored
Normal file
25
vendor/github.com/go-chi/chi/v5/middleware/sunset.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Sunset set Deprecation/Sunset header to response
|
||||
// This can be used to enable Sunset in a route or a route group
|
||||
// For more: https://www.rfc-editor.org/rfc/rfc8594.html
|
||||
func Sunset(sunsetAt time.Time, links ...string) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if !sunsetAt.IsZero() {
|
||||
w.Header().Set("Sunset", sunsetAt.Format(http.TimeFormat))
|
||||
w.Header().Set("Deprecation", sunsetAt.Format(http.TimeFormat))
|
||||
|
||||
for _, link := range links {
|
||||
w.Header().Add("Link", link)
|
||||
}
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
}
|
||||
27
vendor/github.com/go-chi/chi/v5/middleware/supress_notfound.go
generated
vendored
Normal file
27
vendor/github.com/go-chi/chi/v5/middleware/supress_notfound.go
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
// SupressNotFound will quickly respond with a 404 if the route is not found
|
||||
// and will not continue to the next middleware handler.
|
||||
//
|
||||
// This is handy to put at the top of your middleware stack to avoid unnecessary
|
||||
// processing of requests that are not going to match any routes anyway. For
|
||||
// example its super annoying to see a bunch of 404's in your logs from bots.
|
||||
func SupressNotFound(router *chi.Mux) func(next http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
rctx := chi.RouteContext(r.Context())
|
||||
match := rctx.Routes.Match(rctx, r.Method, r.URL.Path)
|
||||
if !match {
|
||||
router.NotFoundHandler().ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
}
|
||||
23
vendor/github.com/go-chi/chi/v5/middleware/timeout.go
generated
vendored
23
vendor/github.com/go-chi/chi/v5/middleware/timeout.go
generated
vendored
@@ -15,21 +15,20 @@ import (
|
||||
//
|
||||
// ie. a route/handler may look like:
|
||||
//
|
||||
// r.Get("/long", func(w http.ResponseWriter, r *http.Request) {
|
||||
// ctx := r.Context()
|
||||
// processTime := time.Duration(rand.Intn(4)+1) * time.Second
|
||||
// r.Get("/long", func(w http.ResponseWriter, r *http.Request) {
|
||||
// ctx := r.Context()
|
||||
// processTime := time.Duration(rand.Intn(4)+1) * time.Second
|
||||
//
|
||||
// select {
|
||||
// case <-ctx.Done():
|
||||
// return
|
||||
// select {
|
||||
// case <-ctx.Done():
|
||||
// return
|
||||
//
|
||||
// case <-time.After(processTime):
|
||||
// // The above channel simulates some hard work.
|
||||
// }
|
||||
//
|
||||
// w.Write([]byte("done"))
|
||||
// })
|
||||
// case <-time.After(processTime):
|
||||
// // The above channel simulates some hard work.
|
||||
// }
|
||||
//
|
||||
// w.Write([]byte("done"))
|
||||
// })
|
||||
func Timeout(timeout time.Duration) func(next http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
37
vendor/github.com/go-chi/chi/v5/middleware/url_format.go
generated
vendored
37
vendor/github.com/go-chi/chi/v5/middleware/url_format.go
generated
vendored
@@ -20,30 +20,29 @@ var (
|
||||
//
|
||||
// Routers should not include a url parameter for the suffix when using this middleware.
|
||||
//
|
||||
// Sample usage.. for url paths: `/articles/1`, `/articles/1.json` and `/articles/1.xml`
|
||||
// Sample usage for url paths `/articles/1`, `/articles/1.json` and `/articles/1.xml`:
|
||||
//
|
||||
// func routes() http.Handler {
|
||||
// r := chi.NewRouter()
|
||||
// r.Use(middleware.URLFormat)
|
||||
// func routes() http.Handler {
|
||||
// r := chi.NewRouter()
|
||||
// r.Use(middleware.URLFormat)
|
||||
//
|
||||
// r.Get("/articles/{id}", ListArticles)
|
||||
// r.Get("/articles/{id}", ListArticles)
|
||||
//
|
||||
// return r
|
||||
// }
|
||||
// return r
|
||||
// }
|
||||
//
|
||||
// func ListArticles(w http.ResponseWriter, r *http.Request) {
|
||||
// urlFormat, _ := r.Context().Value(middleware.URLFormatCtxKey).(string)
|
||||
//
|
||||
// switch urlFormat {
|
||||
// case "json":
|
||||
// render.JSON(w, r, articles)
|
||||
// case "xml:"
|
||||
// render.XML(w, r, articles)
|
||||
// default:
|
||||
// render.JSON(w, r, articles)
|
||||
// }
|
||||
// }
|
||||
// func ListArticles(w http.ResponseWriter, r *http.Request) {
|
||||
// urlFormat, _ := r.Context().Value(middleware.URLFormatCtxKey).(string)
|
||||
//
|
||||
// switch urlFormat {
|
||||
// case "json":
|
||||
// render.JSON(w, r, articles)
|
||||
// case "xml:"
|
||||
// render.XML(w, r, articles)
|
||||
// default:
|
||||
// render.JSON(w, r, articles)
|
||||
// }
|
||||
// }
|
||||
func URLFormat(next http.Handler) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
9
vendor/github.com/go-chi/chi/v5/mux.go
generated
vendored
9
vendor/github.com/go-chi/chi/v5/mux.go
generated
vendored
@@ -250,20 +250,19 @@ func (mx *Mux) With(middlewares ...func(http.Handler) http.Handler) Router {
|
||||
return im
|
||||
}
|
||||
|
||||
// Group creates a new inline-Mux with a fresh middleware stack. It's useful
|
||||
// Group creates a new inline-Mux with a copy of middleware stack. It's useful
|
||||
// for a group of handlers along the same routing path that use an additional
|
||||
// set of middlewares. See _examples/.
|
||||
func (mx *Mux) Group(fn func(r Router)) Router {
|
||||
im := mx.With().(*Mux)
|
||||
im := mx.With()
|
||||
if fn != nil {
|
||||
fn(im)
|
||||
}
|
||||
return im
|
||||
}
|
||||
|
||||
// Route creates a new Mux with a fresh middleware stack and mounts it
|
||||
// along the `pattern` as a subrouter. Effectively, this is a short-hand
|
||||
// call to Mount. See _examples/.
|
||||
// Route creates a new Mux and mounts it along the `pattern` as a subrouter.
|
||||
// Effectively, this is a short-hand call to Mount. See _examples/.
|
||||
func (mx *Mux) Route(pattern string, fn func(r Router)) Router {
|
||||
if fn == nil {
|
||||
panic(fmt.Sprintf("chi: attempting to Route() a nil subrouter on '%s'", pattern))
|
||||
|
||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -805,7 +805,7 @@ github.com/go-acme/lego/v4/challenge
|
||||
# github.com/go-asn1-ber/asn1-ber v1.5.5
|
||||
## explicit; go 1.13
|
||||
github.com/go-asn1-ber/asn1-ber
|
||||
# github.com/go-chi/chi/v5 v5.0.10
|
||||
# github.com/go-chi/chi/v5 v5.0.11
|
||||
## explicit; go 1.14
|
||||
github.com/go-chi/chi/v5
|
||||
github.com/go-chi/chi/v5/middleware
|
||||
|
||||
Reference in New Issue
Block a user