-
Notifications
You must be signed in to change notification settings - Fork 0
/
endpoint.go
43 lines (34 loc) · 1.28 KB
/
endpoint.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
package intake
import "net/http"
type endpoint struct {
Verb string
Path string
EndpointHandler Handler
MiddlewareHandlers []MiddleWare
}
func NewEndpoint(method, path string, endpointHandler Handler, mid ...MiddleWare) endpoint {
return endpoint{
Verb: method,
Path: path,
EndpointHandler: endpointHandler,
MiddlewareHandlers: mid,
}
}
func GET(path string, endpointHandler Handler, mid ...MiddleWare) endpoint {
return NewEndpoint(http.MethodGet, path, endpointHandler, mid...)
}
func POST(path string, endpointHandler Handler, mid ...MiddleWare) endpoint {
return NewEndpoint(http.MethodPost, path, endpointHandler, mid...)
}
func PUT(path string, endpointHandler Handler, mid ...MiddleWare) endpoint {
return NewEndpoint(http.MethodPut, path, endpointHandler, mid...)
}
func DELETE(path string, endpointHandler Handler, mid ...MiddleWare) endpoint {
return NewEndpoint(http.MethodDelete, path, endpointHandler, mid...)
}
func PATCH(path string, endpointHandler Handler, mid ...MiddleWare) endpoint {
return NewEndpoint(http.MethodPatch, path, endpointHandler, mid...)
}
func HEAD(path string, endpointHandler Handler, mid ...MiddleWare) endpoint {
return NewEndpoint(http.MethodHead, path, endpointHandler, mid...)
}