Vlasnik izlazi iz DAL price za ovaj projekat - postaje samostalan proizvod. Preimenovanje je mehanicko (import putanje, imena fajlova/baze/UI naslova), NIJEDNA linija poslovne logike u internal/handler ili internal/service nije dirana - go build, go vet i go test ./... prolaze cisto pod novim imenom. - go.mod: module dal-license-server -> licence-server; 28 import linija u 13 .go fajlova usaglaseno - internal/config/config.go (+test): default DB_NAME licence_db - HTML sabloni (7 stranica) + 7 Playwright e2e spec fajlova: "DAL License Server" -> "Licence Server" u title/nav-brand, testovi usaglaseni u istom prolazu (nista ne moze da se razdvoji) - package.json/package-lock.json/.gitignore/.claude/project.json: ime projekta/binarnog fajla/work_dir - Usput: package.json je u repository.url nosio OTVORENU Gitea lozinku u cistom tekstu - uklonjena (URL sad bez kredencijala). Lozinka je i dalje u staroj git istoriji - preporuka: rotirati je posebno. - CLAUDE.md/README/API/TESTING/docs/SPEC/ARCHITECTURE/SETUP: naslovi, ASCII dijagrami, git clone URL, mysqldump primer, systemd predlozak u SETUP.md zamenjen stvarnim (obrazac terminia.service - journal log + graceful shutdown, ne stari minimalni predlozak) - Debrendiranje: "Univerzalni licencni server za sve DAL proizvode" -> "za vise proizvoda i klijenata"; potpis "Nenad Djukic / DAL d.o.o." -> "Nenad Djukic". NE dirano: nazivi ESIR/ARV/LIGHT_TICKET (tudji proizvodi, ne DAL brend), "DAL" kao stvaran naziv org-a u RBAC modelu (docs/loggerservice/README.md) - to je podatak, ne branding ovog servera. - docs/asp-terminia/, docs/loggerservice/: prozni pomeni imena servera Baza (dal_license_db -> licence_db) i deploy na 151 idu u posebnom koraku, posle preimenovanja Gitea repoa - vidi CLAUDE.md istorijsku belesku na dnu. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
79 lines
3.0 KiB
Go
79 lines
3.0 KiB
Go
package router
|
|
|
|
import (
|
|
"licence-server/internal/handler"
|
|
"licence-server/internal/middleware"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
func Setup(
|
|
client *handler.ClientHandler,
|
|
admin *handler.AdminHandler,
|
|
dashboard *handler.DashboardHandler,
|
|
apiKey string,
|
|
rateLimitActivate int,
|
|
rateLimitValidate int,
|
|
) http.Handler {
|
|
mux := http.NewServeMux()
|
|
|
|
apiKeyMw := middleware.APIKeyAuth(apiKey)
|
|
activateRL := middleware.RateLimit(rateLimitActivate)
|
|
validateRL := middleware.RateLimit(rateLimitValidate)
|
|
|
|
requireAPI := func(f http.HandlerFunc) http.Handler {
|
|
return apiKeyMw(http.HandlerFunc(f))
|
|
}
|
|
requireDash := func(f http.HandlerFunc) http.Handler {
|
|
return dashboard.RequireLogin(http.HandlerFunc(f))
|
|
}
|
|
|
|
// Static files
|
|
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
|
|
|
|
// Health
|
|
mux.HandleFunc("GET /api/v1/health", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Write([]byte(`{"status":"ok"}`))
|
|
})
|
|
|
|
// Client API
|
|
mux.Handle("POST /api/v1/activate", activateRL(http.HandlerFunc(client.Activate)))
|
|
mux.Handle("POST /api/v1/deactivate", activateRL(http.HandlerFunc(client.Deactivate)))
|
|
mux.Handle("POST /api/v1/validate", validateRL(http.HandlerFunc(client.Validate)))
|
|
|
|
// Admin API
|
|
mux.Handle("GET /api/v1/admin/products", requireAPI(admin.ListProducts))
|
|
mux.Handle("GET /api/v1/admin/licenses", requireAPI(admin.ListLicenses))
|
|
mux.Handle("POST /api/v1/admin/licenses", requireAPI(admin.CreateLicense))
|
|
mux.Handle("GET /api/v1/admin/licenses/{id}", requireAPI(admin.GetLicense))
|
|
mux.Handle("PUT /api/v1/admin/licenses/{id}", requireAPI(admin.UpdateLicense))
|
|
mux.Handle("POST /api/v1/admin/licenses/{id}/revoke", requireAPI(admin.RevokeLicense))
|
|
mux.Handle("POST /api/v1/admin/licenses/{id}/release", requireAPI(admin.ReleaseLicense))
|
|
mux.Handle("GET /api/v1/admin/licenses/{id}/activations", requireAPI(admin.ListActivations))
|
|
mux.Handle("GET /api/v1/admin/audit", requireAPI(admin.AuditLog))
|
|
mux.Handle("GET /api/v1/admin/stats", requireAPI(admin.Stats))
|
|
|
|
// Dashboard
|
|
mux.HandleFunc("GET /login", dashboard.LoginPage)
|
|
mux.HandleFunc("POST /login", dashboard.Login)
|
|
mux.Handle("POST /logout", requireDash(dashboard.Logout))
|
|
mux.Handle("GET /dashboard", requireDash(dashboard.Dashboard))
|
|
mux.Handle("GET /licenses", requireDash(dashboard.LicenseList))
|
|
mux.Handle("GET /licenses/new", requireDash(dashboard.LicenseNew))
|
|
mux.Handle("POST /licenses", requireDash(dashboard.LicenseCreate))
|
|
mux.Handle("GET /licenses/{id}", requireDash(dashboard.LicenseDetail))
|
|
mux.Handle("POST /licenses/{id}/revoke", requireDash(dashboard.LicenseRevoke))
|
|
mux.Handle("POST /licenses/{id}/release", requireDash(dashboard.LicenseRelease))
|
|
mux.Handle("GET /audit", requireDash(dashboard.AuditPage))
|
|
|
|
// Root redirect
|
|
mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
|
|
http.Redirect(w, r, "/dashboard", http.StatusSeeOther)
|
|
})
|
|
|
|
_ = strconv.Itoa(0) // satisfy import if needed
|
|
|
|
return mux
|
|
}
|