1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-08-08 22:46:33 +02:00

Add static upstream

This commit is contained in:
Christian Groschupp
2019-09-18 22:40:33 +02:00
parent 62bf233682
commit 1295f87b33
3 changed files with 13 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import (
"net/http/httputil"
"net/url"
"regexp"
"strconv"
"strings"
"time"
@ -207,6 +208,16 @@ func NewOAuthProxy(opts *Options, validator func(string) bool) *OAuthProxy {
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)
if err != nil {
logger.Printf("unable to convert %q to int, use default \"200\"", u.Host)
responseCode = 200
}
rw.WriteHeader(responseCode)
fmt.Fprintf(rw, "Authenticated")
})
case "file":
if u.Fragment != "" {
path = u.Fragment