init
This commit is contained in:
1 parent
7014f56cbb
commit
fe6f1f5e5a
25 files changed
+1918
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/integration-system/isp-lib/structure"
|
||||
"github.com/valyala/fasthttp"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/proxy/grpc"
|
||||
"isp-gate-service/proxy/http"
|
||||
)
|
||||
|
||||
var ProxyStore = make(map[string]Proxy)
|
||||
|
||||
const (
|
||||
httpProtocol = "http"
|
||||
grpcProtocol = "grpc"
|
||||
)
|
||||
|
||||
type Proxy interface {
|
||||
ProxyRequest(ctx *fasthttp.RequestCtx)
|
||||
Consumer([]structure.AddressConfiguration) bool
|
||||
Close()
|
||||
}
|
||||
|
||||
func Init(location conf.Location) (Proxy, error) {
|
||||
switch location.Protocol {
|
||||
case httpProtocol:
|
||||
proxy := http.NewProxy()
|
||||
ProxyStore[location.PathPrefix] = proxy
|
||||
return proxy, nil
|
||||
case grpcProtocol:
|
||||
proxy := grpc.NewProxy()
|
||||
ProxyStore[location.PathPrefix] = proxy
|
||||
return proxy, nil
|
||||
default:
|
||||
return nil, errors.New("unknown protocol")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user