mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-17 22:19:42 +02:00
allow multiple docker providers, added file provider support
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
type HTTPRoute struct {
|
||||
Alias string
|
||||
Url *url.URL
|
||||
Path string
|
||||
PathMode string
|
||||
@@ -31,7 +32,6 @@ func isValidProxyPathMode(mode string) bool {
|
||||
func NewHTTPRoute(config *ProxyConfig) (*HTTPRoute, error) {
|
||||
url, err := url.Parse(fmt.Sprintf("%s://%s:%s", config.Scheme, config.Host, config.Port))
|
||||
if err != nil {
|
||||
glog.Infoln(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ func NewHTTPRoute(config *ProxyConfig) (*HTTPRoute, error) {
|
||||
}
|
||||
|
||||
route := &HTTPRoute{
|
||||
Alias: config.Alias,
|
||||
Url: url,
|
||||
Path: config.Path,
|
||||
Proxy: proxy,
|
||||
@@ -158,6 +159,15 @@ func httpProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
route.Proxy.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func (r *HTTPRoute) RemoveFromRoutes() {
|
||||
routes.HTTPRoutes.Delete(r.Alias)
|
||||
}
|
||||
|
||||
// dummy implementation for Route interface
|
||||
func (r *HTTPRoute) SetupListen() {}
|
||||
func (r *HTTPRoute) Listen() {}
|
||||
func (r *HTTPRoute) StopListening() {}
|
||||
|
||||
// TODO: default + per proxy
|
||||
var transport = &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
|
||||
Reference in New Issue
Block a user