@@ -15,6 +15,7 @@ import (
15
15
"github.com/gorilla/mux"
16
16
"github.com/julienschmidt/httprouter"
17
17
"github.com/justinas/alice"
18
+ "github.com/kataras/iris/v12"
18
19
"github.com/labstack/echo/v4"
19
20
"github.com/prometheus/client_golang/prometheus"
20
21
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -33,6 +34,7 @@ import (
33
34
gojimiddleware "github.com/slok/go-http-metrics/middleware/goji"
34
35
gorestfulmiddleware "github.com/slok/go-http-metrics/middleware/gorestful"
35
36
httproutermiddleware "github.com/slok/go-http-metrics/middleware/httprouter"
37
+ irismiddleware "github.com/slok/go-http-metrics/middleware/iris"
36
38
negronimiddleware "github.com/slok/go-http-metrics/middleware/negroni"
37
39
stdmiddleware "github.com/slok/go-http-metrics/middleware/std"
38
40
)
@@ -82,6 +84,7 @@ func TestMiddlewarePrometheus(t *testing.T) {
82
84
"Alice" : {server : prepareHandlerAlice },
83
85
"Gorilla" : {server : prepareHandlerGorilla },
84
86
"Fasthttp" : {server : prepareHandlerFastHTTP },
87
+ "Iris" : {server : prepareHandlerIris },
85
88
}
86
89
87
90
for name , test := range tests {
@@ -382,3 +385,23 @@ func prepareHandlerFastHTTP(m middleware.Middleware, hc []handlerConfig) server
382
385
383
386
return netListenerServer {ln : ln }
384
387
}
388
+
389
+ func prepareHandlerIris (m middleware.Middleware , hc []handlerConfig ) server {
390
+ // Setup server and middleware.
391
+ app := iris .New ()
392
+ app .Use (irismiddleware .Handler ("" , m ))
393
+
394
+ // Set handlers.
395
+ for _ , h := range hc {
396
+ h := h
397
+ app .Handle (h .Method , h .Path , iris .Handler (func (ctx iris.Context ) {
398
+ time .Sleep (h .SleepDuration )
399
+ ctx .StatusCode (h .Code )
400
+ ctx .WriteString (h .ReturnData ) // nolint: errcheck
401
+ }))
402
+ }
403
+
404
+ app .Build () // nolint: errcheck
405
+
406
+ return testServer {server : httptest .NewServer (app )}
407
+ }
0 commit comments