File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package api
2
2
3
3
import (
4
4
"fmt"
5
+ "net/http"
5
6
"time"
6
7
7
8
"github.com/gin-contrib/cors"
@@ -53,6 +54,11 @@ func (server *Server) setupRouter() {
53
54
54
55
router .GET ("/docs/*any" , ginSwagger .WrapHandler (swaggerFiles .Handler ))
55
56
57
+ // Ping pong tutorial prometheus
58
+ http .HandleFunc ("/ping" , func (w http.ResponseWriter , r * http.Request ) {
59
+ fmt .Print (w , "pong" )
60
+ })
61
+
56
62
router .POST ("/users" , server .createUser )
57
63
router .POST ("/users/login" , server .loginUser )
58
64
// Question
Original file line number Diff line number Diff line change
1
+ package metric
2
+
3
+ import (
4
+ "fmt"
5
+ "net/http"
6
+
7
+ "github.com/prometheus/client_golang/prometheus"
8
+ )
9
+
10
+ func ping (w http.ResponseWriter , req * http.Request ) {
11
+ pingCounter .Inc ()
12
+ fmt .Fprintf (w , "pong" )
13
+ }
14
+
15
+ var pingCounter = prometheus .NewCounter (
16
+ prometheus.CounterOpts {
17
+ Name : "ping_request_count" ,
18
+ Help : "No of request handled by Ping handler" ,
19
+ },
20
+ )
You can’t perform that action at this time.
0 commit comments