File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change
1
+ package endpoints
2
+
3
+ import "strings"
4
+
5
+ // CustomRoute is APIRoute but custom for you
6
+ type CustomRoute struct {
7
+ APIRoute
8
+ }
9
+
10
+ // Compile returns a CompiledAPIRoute
11
+ func (r CustomRoute ) Compile (args ... interface {}) CompiledAPIRoute {
12
+ return CompiledAPIRoute {
13
+ CompiledRoute : r .Route .Compile (args ... ),
14
+ method : r .method ,
15
+ }
16
+ }
17
+
18
+ // NewCustomRoute generates a new custom route struct
19
+ func NewCustomRoute (method Method , url string ) APIRoute {
20
+ urls := strings .SplitN (url , "/" , 2 )
21
+ return APIRoute {
22
+ Route : Route {
23
+ baseRoute : urls [0 ],
24
+ route : urls [1 ],
25
+ paramCount : countParams (url ),
26
+ },
27
+ method : method ,
28
+ }
29
+ }
Original file line number Diff line number Diff line change @@ -5,12 +5,9 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
5
5
github.com/gorilla/mux v1.8.0 /go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So =
6
6
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc =
7
7
github.com/gorilla/websocket v1.4.2 /go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE =
8
- github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g =
9
- github.com/magefile/mage v1.10.0 /go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A =
10
8
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
11
9
github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
12
- github.com/sirupsen/logrus v1.8.0 h1:nfhvjKcUMhBMVqbKHJlk5RPrrfYr/NMo3692g0dwfWU =
13
- github.com/sirupsen/logrus v1.8.0 /go.mod h1:4GuYW9TZmE769R5STWrRakJc4UqQ3+QQ95fyz7ENv1A =
10
+ github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE =
14
11
github.com/sirupsen/logrus v1.8.1 /go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0 =
15
12
github.com/stretchr/objx v0.1.0 /go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME =
16
13
github.com/stretchr/testify v1.2.2 /go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs =
You can’t perform that action at this time.
0 commit comments