mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
23 lines
422 B
Go
23 lines
422 B
Go
|
package middlewares
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
|
||
|
"github.com/valyala/fasthttp"
|
||
|
)
|
||
|
|
||
|
// StripPathMiddleware strips the first level of a path.
|
||
|
func StripPathMiddleware(next fasthttp.RequestHandler) fasthttp.RequestHandler {
|
||
|
return func(ctx *fasthttp.RequestCtx) {
|
||
|
uri := ctx.Request.RequestURI()
|
||
|
n := bytes.IndexByte(uri[1:], '/')
|
||
|
|
||
|
if n >= 0 {
|
||
|
uri = uri[n+1:]
|
||
|
ctx.Request.SetRequestURI(string(uri))
|
||
|
}
|
||
|
|
||
|
next(ctx)
|
||
|
}
|
||
|
}
|