mirror of
https://github.com/foomo/gofoomo.git
synced 2025-10-16 12:25:44 +00:00
exposing ServeHTTPFunc
This commit is contained in:
parent
227c8cb95e
commit
e4f3b99109
@ -18,11 +18,12 @@ type Listener interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Proxy struct {
|
type Proxy struct {
|
||||||
foomo *foomo.Foomo
|
foomo *foomo.Foomo
|
||||||
ReverseProxy *httputil.ReverseProxy
|
ReverseProxy *httputil.ReverseProxy
|
||||||
handlers []Handler
|
handlers []Handler
|
||||||
listeners []Listener
|
listeners []Listener
|
||||||
auth *Auth
|
auth *Auth
|
||||||
|
ServeHTTPFunc func(http.ResponseWriter, *http.Request)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProxyServer struct {
|
type ProxyServer struct {
|
||||||
@ -35,11 +36,16 @@ func NewProxy(f *foomo.Foomo) *Proxy {
|
|||||||
proxy := &Proxy{
|
proxy := &Proxy{
|
||||||
foomo: f,
|
foomo: f,
|
||||||
}
|
}
|
||||||
|
proxy.ServeHTTPFunc = proxy.serveHTTP
|
||||||
proxy.ReverseProxy = httputil.NewSingleHostReverseProxy(proxy.foomo.URL)
|
proxy.ReverseProxy = httputil.NewSingleHostReverseProxy(proxy.foomo.URL)
|
||||||
return proxy
|
return proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, incomingRequest *http.Request) {
|
func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, incomingRequest *http.Request) {
|
||||||
|
proxy.ServeHTTPFunc(w, incomingRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (proxy *Proxy) serveHTTP(w http.ResponseWriter, incomingRequest *http.Request) {
|
||||||
if proxy.auth != nil && len(proxy.auth.Domain) > 0 && !proxy.foomo.BasicAuthForRequest(w, incomingRequest, proxy.auth.Domain, proxy.auth.Realm, "access denied") {
|
if proxy.auth != nil && len(proxy.auth.Domain) > 0 && !proxy.foomo.BasicAuthForRequest(w, incomingRequest, proxy.auth.Domain, proxy.auth.Realm, "access denied") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user