This repository has been archived by the owner on Apr 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
routers.go
93 lines (79 loc) · 1.58 KB
/
routers.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Npcf_UEPolicyControl
*
* UE Policy Control Service API
*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package UEPolicy
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
)
type Route struct {
// Name is the name of this Route.
Name string
// Method is the string for the HTTP method. ex) GET, POST etc..
Method string
// Pattern is the pattern of the URI.
Pattern string
// HandlerFunc is the handler function of this route.
HandlerFunc gin.HandlerFunc
}
type Routes []Route
func NewRouter() *gin.Engine {
router := gin.Default()
AddService(router)
return router
}
func AddService(engine *gin.Engine) *gin.RouterGroup {
group := engine.Group("/npcf-ue-policy-control/v1/")
for _, route := range routes {
switch route.Method {
case "GET":
group.GET(route.Pattern, route.HandlerFunc)
case "POST":
group.POST(route.Pattern, route.HandlerFunc)
case "PATCH":
group.PATCH(route.Pattern, route.HandlerFunc)
}
}
return group
}
func Index(c *gin.Context) {
c.String(http.StatusOK, "Hello World!")
}
var routes = Routes{
{
"Index",
"GET",
"",
Index,
},
{
"PoliciesPolAssoIdDelete",
strings.ToUpper("Delete"),
"/policies/{polAssoId}",
PoliciesPolAssoIdDelete,
},
{
"PoliciesPolAssoIdGet",
strings.ToUpper("Get"),
"/policies/{polAssoId}",
PoliciesPolAssoIdGet,
},
{
"PoliciesPolAssoIdUpdatePost",
strings.ToUpper("Post"),
"/policies/{polAssoId}/update",
PoliciesPolAssoIdUpdatePost,
},
{
"PoliciesPost",
strings.ToUpper("Post"),
"/policies",
PoliciesPost,
},
}