init
This commit is contained in:
1 parent
70f5ebeb4b
commit
3a4931ca8c
7 files changed
+105
-62
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/integration-system/isp-lib/http"
|
||||
"github.com/integration-system/isp-lib/structure"
|
||||
"github.com/valyala/fasthttp"
|
||||
"google.golang.org/grpc/codes"
|
||||
"isp-gate-service/proxy"
|
||||
)
|
||||
|
||||
func Complete(ctx *fasthttp.RequestCtx) {
|
||||
path := string(ctx.Path())
|
||||
|
||||
p := proxy.Find(path)
|
||||
if p != nil {
|
||||
p.ProxyRequest(ctx)
|
||||
} else {
|
||||
statusCode := codes.NotFound
|
||||
response := structure.GrpcError{
|
||||
ErrorMessage: "unknown path", ErrorCode: statusCode.String(),
|
||||
Details: []interface{}{map[string]string{"path": path}},
|
||||
}
|
||||
ctx.Response.Header.SetContentType("application/json; charset=utf-8")
|
||||
ctx.SetStatusCode(http.CodeToHttpStatus(statusCode))
|
||||
message, _ := json.Marshal(response)
|
||||
_, _ = ctx.Write(message)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user