MSP-437 reimplement grpc proxy

This commit is contained in:
d1slike committed 2022-08-04 21:49:13 +03:00
1 parent cd5e286fb0
commit e7a165875d
2 files changed
+96 -97

No files matched your search

+9 -12
View File
@@ -1,27 +1,24 @@
package middleware
import (
"net/http"
"isp-gate-service/request"
)
type Handler interface {
Handle(ctx *Context) error
Handle(ctx *request.Context) error
}
type HandlerFunc func(ctx *Context) error
type HandlerFunc func(ctx *request.Context) error
func (f HandlerFunc) Handle(ctx *Context) error {
func (f HandlerFunc) Handle(ctx *request.Context) error {
return f(ctx)
}
type Middleware func(next Handler) Handler
type Context struct {
Id string
Request *http.Request
ResponseWriter http.ResponseWriter
Path string
AppId int
AdminId int
authenticated bool
func Chain(root Handler, middlewares ...Middleware) Handler {
for i := len(middlewares) - 1; i >= 0; i-- {
root = middlewares[i](root)
}
return root
}