File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
1
package mmbot
2
2
3
- import "net/http"
3
+ import (
4
+ "net/http"
5
+
6
+ "github.com/fukata/golang-stats-api-handler"
7
+ )
4
8
5
9
// RouteHandlerFunc is route action function.
6
10
type RouteHandlerFunc func (* Robot , http.ResponseWriter , * http.Request )
@@ -19,3 +23,25 @@ type Route struct {
19
23
// Route action.
20
24
Action RouteHandlerFunc
21
25
}
26
+
27
+ // NewPingRoute returns the route "ping".
28
+ func NewPingRoute (pattern string ) Route {
29
+ return Route {
30
+ Methods : []string {"GET" },
31
+ Pattern : pattern ,
32
+ Action : func (bot * Robot , w http.ResponseWriter , r * http.Request ) {
33
+ w .Write ([]byte ("pong" ))
34
+ },
35
+ }
36
+ }
37
+
38
+ // NewStatsRoute returns the route for statistics of the process.
39
+ func NewStatsRoute (pattern string ) Route {
40
+ return Route {
41
+ Methods : []string {"GET" },
42
+ Pattern : pattern ,
43
+ Action : func (bot * Robot , w http.ResponseWriter , r * http.Request ) {
44
+ stats_api .Handler (w , r )
45
+ },
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments