init auth
This commit is contained in:
1 parent
3a4931ca8c
commit
b6baa9e5e7
11 files changed
+224
-82
No files matched your search
@@ -6,12 +6,26 @@ import (
|
||||
"github.com/integration-system/isp-lib/structure"
|
||||
"github.com/valyala/fasthttp"
|
||||
"google.golang.org/grpc/codes"
|
||||
"isp-gate-service/authenticate"
|
||||
"isp-gate-service/proxy"
|
||||
)
|
||||
|
||||
func Complete(ctx *fasthttp.RequestCtx) {
|
||||
path := string(ctx.Path())
|
||||
|
||||
if err := authenticate.Compete(ctx); err != nil {
|
||||
statusCode := codes.Unauthenticated
|
||||
response := structure.GrpcError{
|
||||
ErrorMessage: "unauthenticated", ErrorCode: statusCode.String(),
|
||||
Details: []interface{}{err},
|
||||
}
|
||||
ctx.Response.Header.SetContentType("application/json; charset=utf-8")
|
||||
ctx.SetStatusCode(http.CodeToHttpStatus(statusCode))
|
||||
message, _ := json.Marshal(response)
|
||||
_, _ = ctx.Write(message)
|
||||
return
|
||||
}
|
||||
|
||||
p := proxy.Find(path)
|
||||
if p != nil {
|
||||
p.ProxyRequest(ctx)
|
||||
|
||||
Reference in new issue
Block a user