-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (32 loc) · 974 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"main/service"
)
func main() {
// CORS 配置
config := cors.DefaultConfig()
config.AllowAllOrigins = true
config.AllowHeaders = []string{"Authorization"}
router := gin.Default()
router.Use(cors.New(config))
v1 := router.Group("/api/v1")
{
v1.GET("/animes", service.GetAllAnimes)
v1.GET("/animes/:anid", service.GetSingleAnime)
v1.POST("/animes", service.AddNewAnime)
v1.PUT("/animes", service.UpdateAnime)
v1.DELETE("/animes/:anid", service.DeleteAnime)
v1.GET("/animeinfo", service.GetAnimeInfo)
v1.POST("/login", service.Login)
v1.GET("/users", service.GetAllUsers)
v1.PUT("/users", service.UpdateUser)
v1.GET("/users/animes", service.GetUserAnimes)
v1.PUT("/users/password", service.UpdatePassword)
v1.GET("/menus", service.GetAllMenus)
v1.GET("/status/:anid", service.SetPublished)
v1.GET("/bgmname", service.GetBgmName)
}
router.Run(":8081")
}