Created
July 20, 2022 07:48
-
-
Save nidhi-canopas/32e958603936435e73ecb7a049014c4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "github.com/gin-gonic/gin" | |
| "gorm-test/controllers" | |
| "net/http" | |
| ) | |
| func main() { | |
| r := setupRouter() | |
| _ = r.Run(":8080") | |
| } | |
| func setupRouter() *gin.Engine { | |
| r := gin.Default() | |
| r.GET("ping", func(c *gin.Context) { | |
| c.JSON(http.StatusOK, "pong") | |
| }) | |
| userRepo := controllers.New() | |
| r.POST("/users", userRepo.CreateUser) | |
| r.GET("/users", userRepo.GetUsers) | |
| r.GET("/users/:id", userRepo.GetUser) | |
| r.PUT("/users/:id", userRepo.UpdateUser) | |
| r.DELETE("/users/:id", userRepo.DeleteUser) | |
| return r | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment