-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (42 loc) · 1.37 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2023 Christoph Fichtmüller. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package jug
import "net/http"
func Default() Engine {
return defaultGinEngine()
}
func New() Engine {
return newGinEngine()
}
type Validatable interface {
Validate() error
}
type Engine interface {
RouterGroup
NoMethod(handlers ...HandlerFunc)
NoRoute(handlers ...HandlerFunc)
// ExpandMethods expands each non-configured method for each path to return 405 Method not allowed
ExpandMethods()
Run(addr ...string) error
EnableDebugMode()
ServeHTTP(w http.ResponseWriter, req *http.Request)
}
type RouterGroup interface {
Router
Group(relativePath string, handlers ...HandlerFunc) RouterGroup
}
type Router interface {
Use(middleware ...HandlerFunc) Router
Any(relativePath string, handlers ...HandlerFunc) Router
GET(relativePath string, handlers ...HandlerFunc) Router
POST(relativePath string, handlers ...HandlerFunc) Router
PUT(relativePath string, handlers ...HandlerFunc) Router
DELETE(relativePath string, handlers ...HandlerFunc) Router
PATCH(relativePath string, handlers ...HandlerFunc) Router
OPTIONS(relativePath string, handlers ...HandlerFunc) Router
HEAD(relativePath string, handlers ...HandlerFunc) Router
}
func MethodNotAllowed(c Context) {
c.Status(http.StatusMethodNotAllowed)
}