File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 1
1
package coderd
2
2
3
3
import (
4
+ "context"
5
+ "fmt"
4
6
"net/http"
5
7
"net/url"
6
8
"sync"
@@ -56,6 +58,7 @@ func New(options *Options) (http.Handler, func()) {
56
58
chitrace .Middleware (),
57
59
// Specific routes can specify smaller limits.
58
60
httpmw .RateLimitPerMinute (512 ),
61
+ debugLogRequest (api .Logger ),
59
62
)
60
63
r .Get ("/" , func (w http.ResponseWriter , r * http.Request ) {
61
64
httpapi .Write (w , http .StatusOK , httpapi.Response {
@@ -231,3 +234,12 @@ type api struct {
231
234
websocketWaitMutex sync.Mutex
232
235
websocketWaitGroup sync.WaitGroup
233
236
}
237
+
238
+ func debugLogRequest (log slog.Logger ) func (http.Handler ) http.Handler {
239
+ return func (next http.Handler ) http.Handler {
240
+ return http .HandlerFunc (func (rw http.ResponseWriter , r * http.Request ) {
241
+ log .Debug (context .Background (), fmt .Sprintf ("%s %s" , r .Method , r .URL .Path ))
242
+ next .ServeHTTP (rw , r )
243
+ })
244
+ }
245
+ }
You can’t perform that action at this time.
0 commit comments