admin only route is working
This commit is contained in:
14
main.go
14
main.go
@@ -25,7 +25,7 @@ func main() {
|
||||
|
||||
router := gin.Default()
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
time.Sleep(10 * time.Second)
|
||||
//time.Sleep(10 * time.Second)
|
||||
c.String(http.StatusOK, "Welcome Gin Server")
|
||||
})
|
||||
|
||||
@@ -36,18 +36,18 @@ func main() {
|
||||
|
||||
// Register our routes
|
||||
public := router.Group("/api")
|
||||
public.POST("/register", controllers.Register)
|
||||
public.POST("/login", controllers.Login)
|
||||
|
||||
// This is just PoC really, we can get rid of it
|
||||
//protected := r.Group("/api/admin")
|
||||
//protected.Use(middlewares.JwtAuthMiddleware())
|
||||
//protected.GET("/user", controllers.CurrentUser)
|
||||
// TODO - this should be an authenticated route
|
||||
adminOnly := router.Group("/api/admin")
|
||||
adminOnly.Use(middlewares.JwtAuthAdminMiddleware())
|
||||
adminOnly.POST("/register", controllers.Register)
|
||||
|
||||
// Get secrets
|
||||
protected := router.Group("/api/secret")
|
||||
protected.Use(middlewares.JwtAuthMiddleware())
|
||||
protected.GET("/device", controllers.CurrentUser)
|
||||
protected.GET("/retrieve", controllers.Retrieve)
|
||||
protected.POST("/store", controllers.Store)
|
||||
|
||||
// Initializing the server in a goroutine so that
|
||||
// it won't block the graceful shutdown handling below
|
||||
|
Reference in New Issue
Block a user