/
route.go
74 lines (55 loc) · 1.84 KB
/
route.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
package cp
import (
"net/http"
"github.com/creamsensation/cp/internal/handler"
"github.com/creamsensation/cp/internal/route"
)
type Routes []*route.Builder
func Route(configs ...route.Config) *route.Builder {
return route.CreateBuilder(configs...)
}
func Name(name string) route.Config {
return route.CreateConfig(route.ConfigName, name)
}
func Path(path route.PathValue) route.Config {
return route.CreatePathConfig(path)
}
func Layout(name string) route.Config {
return route.CreateConfig(route.ConfigLayout, name)
}
func Localize() route.Config {
return route.CreateConfig(route.ConfigLocalize, true)
}
func Handler(fn handler.Fn) route.Config {
return route.CreateConfig(route.ConfigHandler, fn)
}
func Method(methods ...route.Config) route.Config {
return route.CreateMethodConfig(methods...)
}
func Get(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodGet, path...)
}
func Post(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodPost, path...)
}
func Put(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodPut, path...)
}
func Patch(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodPatch, path...)
}
func Delete(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodDelete, path...)
}
func Options(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodOptions, path...)
}
func Head(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodHead, path...)
}
func Trace(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodTrace, path...)
}
func Connect(path ...route.PathValue) route.Config {
return route.CreateMethodPathConfig(http.MethodConnect, path...)
}