2023-04-24 20:52:12 +02:00
|
|
|
package director
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2024-03-29 09:21:01 +01:00
|
|
|
"net/url"
|
2023-04-24 20:52:12 +02:00
|
|
|
|
|
|
|
"forge.cadoles.com/Cadoles/go-proxy"
|
|
|
|
"forge.cadoles.com/Cadoles/go-proxy/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
func createMiddlewareChain(handler http.Handler, middlewares []proxy.Middleware) http.Handler {
|
|
|
|
util.Reverse(middlewares)
|
|
|
|
|
|
|
|
for _, m := range middlewares {
|
|
|
|
handler = m(handler)
|
|
|
|
}
|
|
|
|
|
|
|
|
return handler
|
|
|
|
}
|
2024-03-29 09:21:01 +01:00
|
|
|
|
|
|
|
func getRequestURL(r *http.Request) *url.URL {
|
|
|
|
scheme := "http"
|
|
|
|
if r.URL.Scheme != "" {
|
|
|
|
scheme = r.URL.Scheme
|
|
|
|
}
|
|
|
|
|
|
|
|
url := url.URL{
|
|
|
|
Host: r.Host,
|
|
|
|
Scheme: scheme,
|
|
|
|
Path: r.URL.Path,
|
|
|
|
RawQuery: r.URL.RawQuery,
|
|
|
|
}
|
|
|
|
|
|
|
|
return &url
|
|
|
|
}
|