feat: handle port forward subdomain conflict
This commit is contained in:
5
internal/reverseproxy/errors.go
Normal file
5
internal/reverseproxy/errors.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package reverseproxy
|
||||
|
||||
import "errors"
|
||||
|
||||
var ErrPortMappingConflict = errors.New("port mapping conflict")
|
@@ -43,9 +43,14 @@ func (p *ReverseProxy) Middleware() echo.MiddlewareFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ReverseProxy) AddEntry(subdomain string, url *url.URL) {
|
||||
func (p *ReverseProxy) AddEntry(subdomain string, url *url.URL) error {
|
||||
_, ok := p.httpProxies[subdomain]
|
||||
if ok {
|
||||
return ErrPortMappingConflict
|
||||
}
|
||||
proxy := httputil.NewSingleHostReverseProxy(url)
|
||||
p.httpProxies[subdomain] = proxy
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ReverseProxy) RemoveEntry(subdomain string) {
|
||||
|
Reference in New Issue
Block a user