Setup boilerplate gorm , and admin part
This commit is contained in:
21
routes/protectedRoutes.go
Normal file
21
routes/protectedRoutes.go
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Created by VoidArtanis on 10/22/2017
|
||||
*/
|
||||
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/VoidArtanis/go-rest-boilerplate/middlewares"
|
||||
"github.com/VoidArtanis/go-rest-boilerplate/controllers"
|
||||
)
|
||||
|
||||
func RegisterProtectedRoutes(r *gin.Engine){
|
||||
|
||||
authGroup := r.Group("/auth")
|
||||
|
||||
authGroup.Use(middlewares.AuthHandler("admin"))
|
||||
{
|
||||
authGroup.GET("/getmessage",controllers.GetSecretText)
|
||||
}
|
||||
}
|
||||
16
routes/publicRoutes.go
Normal file
16
routes/publicRoutes.go
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Created by VoidArtanis on 10/22/2017
|
||||
*/
|
||||
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/VoidArtanis/go-rest-boilerplate/controllers"
|
||||
)
|
||||
|
||||
func RegisterPublicRoutes(r *gin.Engine){
|
||||
|
||||
r.GET("/publicmessage", controllers.GetPublicText)
|
||||
}
|
||||
|
||||
24
routes/router.go
Normal file
24
routes/router.go
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Created by VoidArtanis on 10/22/2017
|
||||
*/
|
||||
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/VoidArtanis/go-rest-boilerplate/controllers"
|
||||
"github.com/VoidArtanis/go-rest-boilerplate/middlewares"
|
||||
)
|
||||
|
||||
func InitRouter(engine *gin.Engine) {
|
||||
InitMiddleware(engine)
|
||||
authController := new(controllers.AuthController)
|
||||
engine.POST("/login", authController.HandleLogin)
|
||||
RegisterProtectedRoutes(engine)
|
||||
RegisterPublicRoutes(engine)
|
||||
RegisterUtilityRoutes(engine)
|
||||
}
|
||||
|
||||
func InitMiddleware(engine *gin.Engine){
|
||||
engine.Use(middlewares.CORSMiddleware());
|
||||
}
|
||||
18
routes/utilityRoutes.go
Normal file
18
routes/utilityRoutes.go
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Created by VoidArtanis on 10/22/2017
|
||||
*/
|
||||
|
||||
package routes
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func RegisterUtilityRoutes(r *gin.Engine){
|
||||
registerRing(r)
|
||||
}
|
||||
|
||||
func registerRing(r *gin.Engine){
|
||||
// Ping test
|
||||
r.GET("/ping", func(c *gin.Context) {
|
||||
c.String(200, "pong")
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user