Enabled the authorization middleware
This commit is contained in:
@@ -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.
|
||||
+3
-8
@@ -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.Use(APIAuthMiddleWare())
|
||||
{
|
||||
authGroup.GET("/sw/:id", get)
|
||||
authGroup.GET("/count", count)
|
||||
}
|
||||
|
||||
// Star the SW service
|
||||
err := sw.StartSWService(sw.FILEDB)
|
||||
|
||||
Reference in New Issue
Block a user