Refactoring

This commit is contained in:
PB
2025-11-06 17:55:56 +01:00
parent 988479dc5d
commit 3d8cd00256
24 changed files with 133 additions and 152 deletions

View File

@@ -61,7 +61,7 @@ func (s *Server) Start() error {
crt, err := tls.LoadX509KeyPair("certs/identity-svc.crt", "certs/identity-svc.key")
if err != nil {
log.Fatal(err)
log.Fatal("failed to load certificates: ", err)
}
tlsCnf := &tls.Config{Certificates: []tls.Certificate{crt}}
@@ -74,8 +74,8 @@ func (s *Server) Start() error {
func (s *Server) OnShutdown() {
log.Printf("Server %s is going down...", s.ID)
s.getDatabase().Close()
s.getCache().Close()
s.GetDatabase().Close()
s.GetCache().Close()
s.Shutdown()
}
@@ -84,13 +84,13 @@ func (s *Server) setupRouter() {
s.Options("*", defaultCORS)
s.Use(defaultCORS)
s.Get("/health", http.HealthHandlerFn(s.getDatabase(), s.getCache()))
s.Get("/health", http.HealthHandlerFn(s.GetDatabase(), s.GetCache()))
s.Group("/v1").
Post("/login", http.LoginHandlerFn(s.getDatabase(), s.getCache())).
Post("/refresh", http.RefreshHandlerFn(s.getDatabase(), s.getCache())). // add JWTProtected() and get token from Auth Bearer header not from the body?
Post("/register", http.RegisterHandlerFn(s.getDatabase(), s.getCache())).
Get("/access", JWTProtected(), http.AccessHandlerFn(s.getDatabase(), s.getCache()))
Post("/login", http.LoginHandlerFn(s.GetDatabase(), s.GetCache())).
Post("/refresh", http.RefreshHandlerFn(s.GetDatabase(), s.GetCache())). // add JWTProtected() and get token from Auth Bearer header not from the body?
Post("/register", http.RegisterHandlerFn(s.GetDatabase(), s.GetCache())).
Get("/access", JWTProtected(), http.AccessHandlerFn(s.GetDatabase(), s.GetCache()))
}
func (s *Server) setupMiddleware() {