fixed route gone after container restart / Brename

This commit is contained in:
yusing
2024-10-02 15:38:36 +08:00
parent a7a922308e
commit aa16287447
6 changed files with 43 additions and 21 deletions

View File

@@ -2,7 +2,6 @@ package middleware
import (
"net"
"net/http"
D "github.com/yusing/go-proxy/internal/docker"
E "github.com/yusing/go-proxy/internal/error"
@@ -52,11 +51,8 @@ var realIPOptsDefault = func() *realIPOpts {
func NewRealIP(opts OptionsRaw) (*Middleware, E.NestedError) {
riWithOpts := new(realIP)
riWithOpts.m = &Middleware{
impl: riWithOpts,
before: func(next http.HandlerFunc, w ResponseWriter, r *Request) {
riWithOpts.setRealIP(r)
next(w, r)
},
impl: riWithOpts,
before: Rewrite(riWithOpts.setRealIP),
}
riWithOpts.realIPOpts = realIPOptsDefault()
err := Deserialize(opts, riWithOpts.realIPOpts)

View File

@@ -2,7 +2,6 @@ package middleware
import (
"net"
"net/http"
)
const (
@@ -15,7 +14,7 @@ const (
)
var SetXForwarded = &Middleware{
before: func(next http.HandlerFunc, w ResponseWriter, req *Request) {
before: Rewrite(func(req *Request) {
req.Header.Del("Forwarded")
req.Header.Del(xForwardedFor)
req.Header.Del(xForwardedHost)
@@ -32,16 +31,14 @@ var SetXForwarded = &Middleware{
} else {
req.Header.Set(xForwardedProto, "https")
}
next(w, req)
},
}),
}
var HideXForwarded = &Middleware{
before: func(next http.HandlerFunc, w ResponseWriter, req *Request) {
before: Rewrite(func(req *Request) {
req.Header.Del("Forwarded")
req.Header.Del(xForwardedFor)
req.Header.Del(xForwardedHost)
req.Header.Del(xForwardedProto)
next(w, req)
},
}),
}