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.
|
||||||
+5
-10
@@ -1,10 +1,8 @@
|
|||||||
// Package api will server the SW data via a JSON REST API.
|
// Package api will server the SW data via a JSON REST API.
|
||||||
package api
|
package api
|
||||||
|
|
||||||
// TODO: configure the logging
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
// _ "net/http/pprof"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
sw "github.com/ESilva15/PTInvCertSWDB/sw"
|
sw "github.com/ESilva15/PTInvCertSWDB/sw"
|
||||||
@@ -46,22 +44,19 @@ func get(c *gin.Context) {
|
|||||||
|
|
||||||
func count(c *gin.Context) {
|
func count(c *gin.Context) {
|
||||||
count := sw.Count()
|
count := sw.Count()
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{"count": count})
|
c.JSON(http.StatusOK, gin.H{"count": count})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunServer() error {
|
func RunServer() error {
|
||||||
// go func() {
|
|
||||||
// http.ListenAndServe("localhost:6060", nil)
|
|
||||||
// }()
|
|
||||||
|
|
||||||
gin.SetMode(ginMode)
|
gin.SetMode(ginMode)
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
|
|
||||||
authGroup := router.Group("/")
|
authGroup := router.Group("/")
|
||||||
// authGroup.Use(APIAuthMiddleWare())
|
authGroup.Use(APIAuthMiddleWare())
|
||||||
authGroup.GET("/sw/:id", get)
|
{
|
||||||
authGroup.GET("/count", count)
|
authGroup.GET("/sw/:id", get)
|
||||||
|
authGroup.GET("/count", count)
|
||||||
|
}
|
||||||
|
|
||||||
// Star the SW service
|
// Star the SW service
|
||||||
err := sw.StartSWService(sw.FILEDB)
|
err := sw.StartSWService(sw.FILEDB)
|
||||||
|
|||||||
Reference in New Issue
Block a user