Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
6372e221
Commit
6372e221
authored
Sep 13, 2017
by
bergquist
Committed by
Carl Bergquist
Sep 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate handlers to new register
parent
f8422653
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
pkg/api/api.go
+0
-0
pkg/api/route_register.go
+19
-4
pkg/api/route_register_test.go
+3
-1
No files found.
pkg/api/api.go
View file @
6372e221
This diff is collapsed.
Click to expand it.
pkg/api/route_register.go
View file @
6372e221
...
...
@@ -7,7 +7,7 @@ import (
)
type
Router
interface
{
Route
(
pattern
,
method
string
,
handlers
...
macaron
.
Handler
)
Handle
(
method
,
pattern
string
,
handlers
[]
macaron
.
Handler
)
*
macaron
.
Route
}
type
RouteRegister
interface
{
...
...
@@ -15,10 +15,12 @@ type RouteRegister interface {
Post
(
string
,
...
macaron
.
Handler
)
Delete
(
string
,
...
macaron
.
Handler
)
Put
(
string
,
...
macaron
.
Handler
)
Patch
(
string
,
...
macaron
.
Handler
)
Any
(
string
,
...
macaron
.
Handler
)
Group
(
string
,
func
(
RouteRegister
),
...
macaron
.
Handler
)
Register
(
Router
)
Register
(
Router
)
*
macaron
.
Router
}
func
newRouteRegister
()
RouteRegister
{
...
...
@@ -53,17 +55,22 @@ func (rr *routeRegister) Group(pattern string, fn func(rr RouteRegister), handle
rr
.
groups
=
append
(
rr
.
groups
,
group
)
}
func
(
rr
*
routeRegister
)
Register
(
router
Router
)
{
func
(
rr
*
routeRegister
)
Register
(
router
Router
)
*
macaron
.
Router
{
for
_
,
r
:=
range
rr
.
routes
{
router
.
Route
(
r
.
pattern
,
r
.
method
,
r
.
handlers
...
)
router
.
Handle
(
r
.
method
,
r
.
pattern
,
r
.
handlers
)
}
for
_
,
g
:=
range
rr
.
groups
{
g
.
Register
(
router
)
}
return
&
macaron
.
Router
{}
}
func
(
rr
*
routeRegister
)
route
(
pattern
,
method
string
,
handlers
...
macaron
.
Handler
)
{
//inject metrics
//inject tracing
rr
.
routes
=
append
(
rr
.
routes
,
route
{
method
:
method
,
pattern
:
rr
.
prefix
+
pattern
,
...
...
@@ -86,3 +93,11 @@ func (rr *routeRegister) Delete(pattern string, handlers ...macaron.Handler) {
func
(
rr
*
routeRegister
)
Put
(
pattern
string
,
handlers
...
macaron
.
Handler
)
{
rr
.
route
(
pattern
,
http
.
MethodPut
,
handlers
...
)
}
func
(
rr
*
routeRegister
)
Patch
(
pattern
string
,
handlers
...
macaron
.
Handler
)
{
rr
.
route
(
pattern
,
http
.
MethodPatch
,
handlers
...
)
}
func
(
rr
*
routeRegister
)
Any
(
pattern
string
,
handlers
...
macaron
.
Handler
)
{
rr
.
route
(
pattern
,
"*"
,
handlers
...
)
}
pkg/api/route_register_test.go
View file @
6372e221
...
...
@@ -11,12 +11,14 @@ type fakeRouter struct {
route
[]
route
}
func
(
fr
*
fakeRouter
)
Route
(
pattern
,
method
string
,
handlers
...
macaron
.
Handler
)
{
func
(
fr
*
fakeRouter
)
Handle
(
method
,
pattern
string
,
handlers
[]
macaron
.
Handler
)
*
macaron
.
Route
{
fr
.
route
=
append
(
fr
.
route
,
route
{
pattern
:
pattern
,
method
:
method
,
handlers
:
handlers
,
})
return
&
macaron
.
Route
{}
}
func
emptyHandlers
(
n
int
)
[]
macaron
.
Handler
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment