...
1
2
3
4
5 package ginS
6
7 import (
8 "html/template"
9 "net/http"
10 "sync"
11
12 "github.com/gin-gonic/gin"
13 )
14
15 var once sync.Once
16 var internalEngine *gin.Engine
17
18 func engine() *gin.Engine {
19 once.Do(func() {
20 internalEngine = gin.Default()
21 })
22 return internalEngine
23 }
24
25
26 func LoadHTMLGlob(pattern string) {
27 engine().LoadHTMLGlob(pattern)
28 }
29
30
31 func LoadHTMLFiles(files ...string) {
32 engine().LoadHTMLFiles(files...)
33 }
34
35
36 func SetHTMLTemplate(templ *template.Template) {
37 engine().SetHTMLTemplate(templ)
38 }
39
40
41 func NoRoute(handlers ...gin.HandlerFunc) {
42 engine().NoRoute(handlers...)
43 }
44
45
46 func NoMethod(handlers ...gin.HandlerFunc) {
47 engine().NoMethod(handlers...)
48 }
49
50
51
52 func Group(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup {
53 return engine().Group(relativePath, handlers...)
54 }
55
56
57 func Handle(httpMethod, relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
58 return engine().Handle(httpMethod, relativePath, handlers...)
59 }
60
61
62 func POST(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
63 return engine().POST(relativePath, handlers...)
64 }
65
66
67 func GET(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
68 return engine().GET(relativePath, handlers...)
69 }
70
71
72 func DELETE(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
73 return engine().DELETE(relativePath, handlers...)
74 }
75
76
77 func PATCH(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
78 return engine().PATCH(relativePath, handlers...)
79 }
80
81
82 func PUT(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
83 return engine().PUT(relativePath, handlers...)
84 }
85
86
87 func OPTIONS(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
88 return engine().OPTIONS(relativePath, handlers...)
89 }
90
91
92 func HEAD(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
93 return engine().HEAD(relativePath, handlers...)
94 }
95
96
97 func Any(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
98 return engine().Any(relativePath, handlers...)
99 }
100
101
102 func StaticFile(relativePath, filepath string) gin.IRoutes {
103 return engine().StaticFile(relativePath, filepath)
104 }
105
106
107
108
109
110
111
112
113 func Static(relativePath, root string) gin.IRoutes {
114 return engine().Static(relativePath, root)
115 }
116
117
118 func StaticFS(relativePath string, fs http.FileSystem) gin.IRoutes {
119 return engine().StaticFS(relativePath, fs)
120 }
121
122
123
124
125 func Use(middlewares ...gin.HandlerFunc) gin.IRoutes {
126 return engine().Use(middlewares...)
127 }
128
129
130 func Routes() gin.RoutesInfo {
131 return engine().Routes()
132 }
133
134
135
136
137 func Run(addr ...string) (err error) {
138 return engine().Run(addr...)
139 }
140
141
142
143
144 func RunTLS(addr, certFile, keyFile string) (err error) {
145 return engine().RunTLS(addr, certFile, keyFile)
146 }
147
148
149
150
151 func RunUnix(file string) (err error) {
152 return engine().RunUnix(file)
153 }
154
155
156
157
158 func RunFd(fd int) (err error) {
159 return engine().RunFd(fd)
160 }
161
View as plain text