1
- package httpmw
1
+ package httpmw_test
2
2
3
3
import (
4
4
"context"
@@ -12,6 +12,7 @@ import (
12
12
"github.com/stretchr/testify/assert"
13
13
"github.com/stretchr/testify/require"
14
14
15
+ "github.com/coder/coder/v2/coderd/httpmw"
15
16
"github.com/coder/coder/v2/coderd/tracing"
16
17
"github.com/coder/coder/v2/testutil"
17
18
"github.com/coder/websocket"
@@ -39,7 +40,7 @@ func TestPrometheus(t *testing.T) {
39
40
req = req .WithContext (context .WithValue (req .Context (), chi .RouteCtxKey , chi .NewRouteContext ()))
40
41
res := & tracing.StatusWriter {ResponseWriter : httptest .NewRecorder ()}
41
42
reg := prometheus .NewRegistry ()
42
- Prometheus (reg )(http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
43
+ httpmw . Prometheus (reg )(http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
43
44
w .WriteHeader (http .StatusOK )
44
45
})).ServeHTTP (res , req )
45
46
metrics , err := reg .Gather ()
@@ -54,7 +55,7 @@ func TestPrometheus_Concurrent(t *testing.T) {
54
55
defer cancel ()
55
56
56
57
reg := prometheus .NewRegistry ()
57
- promMW := Prometheus (reg )
58
+ promMW := httpmw . Prometheus (reg )
58
59
59
60
// Create a test handler to simulate a WebSocket connection
60
61
testHandler := http .HandlerFunc (func (rw http.ResponseWriter , r * http.Request ) {
@@ -93,7 +94,7 @@ func TestPrometheus_Concurrent(t *testing.T) {
93
94
func TestGetRoutePattern_UserRoute (t * testing.T ) {
94
95
t .Parallel ()
95
96
reg := prometheus .NewRegistry ()
96
- promMW := Prometheus (reg )
97
+ promMW := httpmw . Prometheus (reg )
97
98
98
99
r := chi .NewRouter ()
99
100
r .With (promMW ).Get ("/api/v2/users/{user}" , func (w http.ResponseWriter , r * http.Request ) {})
0 commit comments