upgrade code

This commit is contained in:
ctengiz
2025-01-15 11:50:12 +03:00
parent 20e4a15286
commit a2215b9363
7 changed files with 78 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ package api
import (
"fmt"
"git.makki.io/makki/libgo/mhttp"
"git.notitek.com.tr/common/notgo/napi"
"git.notitek.com.tr/common/notgo/nauth"
"net/http"
@@ -19,6 +20,20 @@ import (
)
func HttpHandler(re enums.TRunEnv) http.Handler {
lookup := &mhttp.Lookup{
DoClientCheck: true,
Funcs: map[string]mhttp.LookupFunc{
"entegrator": napi.Entegrators,
"invmarket": napi.InvMarket,
"usr": napi.Usr,
"rates": napi.Currency,
},
CompanyCheckQueries: []string{"mmitem", "acchart", "ficomp"},
JwtAuth: svc.S.JWT,
}
mux := chi.NewRouter()
// Gerekli middleware stack
@@ -55,11 +70,20 @@ func HttpHandler(re enums.TRunEnv) http.Handler {
//protected end points
mr.Group(func(r chi.Router) {
// Seek, verify and validate JWT tokens
r.Use(jwtauth.Verifier(svc.S.JWT))
r.Use(jwtauth.Verify(svc.S.JWT, jwtauth.TokenFromHeader, jwtauth.TokenFromCookie, jwtauth.TokenFromQuery))
// Handle valid / invalid tokens.
r.Use(nauth.CheckTokenValidity)
// Set clientID
r.Use(nauth.ClientID)
// Handle valid / invalid tokens.
r.Use(nauth.CheckTokenValidity)
// lookup
r.Method("post", "/lookup/{query}", lookup)
// sy routes
r.Get("/sy/companies", napi.CompanyList)