1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-11-29 22:48:19 +02:00

Add tests for static upstream

This commit is contained in:
Christian Groschupp
2019-09-19 11:03:38 +02:00
parent 1295f87b33
commit dc36836800
2 changed files with 63 additions and 5 deletions

View File

@@ -202,17 +202,17 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
}
for _, u := range opts.proxyURLs {
path := u.Path
host := u.Host
switch u.Scheme {
case httpScheme, httpsScheme:
logger.Printf("mapping path %q => upstream %q", path, u)
proxy := NewWebSocketOrRestReverseProxy(u, opts, auth)
serveMux.Handle(path, proxy)
case "static":
serveMux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
responseCode, err := strconv.Atoi(u.Host)
serveMux.HandleFunc(path, func(rw http.ResponseWriter, req *http.Request) {
responseCode, err := strconv.Atoi(host)
if err != nil {
logger.Printf("unable to convert %q to int, use default \"200\"", u.Host)
logger.Printf("unable to convert %q to int, use default \"200\"", host)
responseCode = 200
}
rw.WriteHeader(responseCode)