Add ping
This commit is contained in:
parent
d5c898520d
commit
ecdc3b235c
|
@ -32,20 +32,18 @@ func main() {
|
|||
r := gin.Default()
|
||||
docs.SwaggerInfo.BasePath = "/api"
|
||||
r.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{"http://localhost:3001"},
|
||||
AllowMethods: []string{"GET", "DELETE", "PUT", "PATCH"},
|
||||
AllowOrigins: []string{"*"},
|
||||
AllowMethods: []string{"GET", "DELETE", "PUT", "PATCH", "OPTIONS"},
|
||||
AllowHeaders: []string{"Origin"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
AllowOriginFunc: func(origin string) bool {
|
||||
return origin == "https://github.com"
|
||||
},
|
||||
MaxAge: 12 * time.Hour,
|
||||
}))
|
||||
|
||||
// Routes defined in the routes package
|
||||
api := r.Group("/api")
|
||||
{
|
||||
api.GET("/ping", handlers.PingGet)
|
||||
userRoutes := api.Group("/user")
|
||||
{
|
||||
userRoutes.POST("/register", handlers.UserRegister)
|
||||
|
|
17
handlers/ping.go
Normal file
17
handlers/ping.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"git.qowevisa.me/Qowevisa/gonuts/types"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Summary Ping
|
||||
// @Description Pong
|
||||
// @Tags user
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} types.Message
|
||||
// @Router /ping [get]
|
||||
func PingGet(c *gin.Context) {
|
||||
c.JSON(200, types.Message{Message: "Pong!"})
|
||||
}
|
Loading…
Reference in New Issue
Block a user