Enabled the authorization middleware

This commit is contained in:
2025-09-21 14:21:04 +01:00
parent 3821c3fffc
commit 2c92ee61a0
2 changed files with 10 additions and 10 deletions
+5
View File
@@ -0,0 +1,5 @@
# CertifiedInvSWDB
Small API to serve the currently existing certified invoicing softwares in
Portugal.
With it there's a small CLI to help scraping new data to populate the DB.
+5 -10
View File
@@ -1,10 +1,8 @@
// Package api will server the SW data via a JSON REST API.
package api
// TODO: configure the logging
import (
"net/http"
// _ "net/http/pprof"
"strconv"
sw "github.com/ESilva15/PTInvCertSWDB/sw"
@@ -46,22 +44,19 @@ func get(c *gin.Context) {
func count(c *gin.Context) {
count := sw.Count()
c.JSON(http.StatusOK, gin.H{"count": count})
}
func RunServer() error {
// go func() {
// http.ListenAndServe("localhost:6060", nil)
// }()
gin.SetMode(ginMode)
router := gin.Default()
authGroup := router.Group("/")
// authGroup.Use(APIAuthMiddleWare())
authGroup.GET("/sw/:id", get)
authGroup.GET("/count", count)
authGroup.Use(APIAuthMiddleWare())
{
authGroup.GET("/sw/:id", get)
authGroup.GET("/count", count)
}
// Star the SW service
err := sw.StartSWService(sw.FILEDB)