File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 22
33import org .juv25d .filter .IpFilter ;
44import org .juv25d .filter .LoggingFilter ;
5+ import org .juv25d .filter .TimingFilter ;
56import org .juv25d .logging .ServerLogging ;
67import org .juv25d .http .HttpParser ;
78import org .juv25d .plugin .NotFoundPlugin ; // New import
@@ -27,6 +28,7 @@ public static void main(String[] args) {
2728 Set .of ()
2829 ), 0 );
2930 pipeline .addGlobalFilter (new LoggingFilter (), 0 );
31+ pipeline .addGlobalFilter (new TimingFilter (), 0 );
3032
3133 // Initialize and configure SimpleRouter
3234 SimpleRouter router = new SimpleRouter ();
Original file line number Diff line number Diff line change 1+ package org .juv25d .filter ;
2+
3+ import org .juv25d .http .HttpRequest ;
4+ import org .juv25d .http .HttpResponse ;
5+ import org .juv25d .logging .ServerLogging ;
6+
7+ import java .io .IOException ;
8+ import java .util .logging .Logger ;
9+
10+ public class TimingFilter implements Filter {
11+
12+ private static final Logger logger = ServerLogging .getLogger ();
13+
14+ @ Override
15+ public void doFilter (HttpRequest req , HttpResponse res , FilterChain chain ) throws IOException {
16+ long start = System .nanoTime ();
17+
18+ chain .doFilter (req , res );
19+
20+ long durationMs = (System .nanoTime () - start ) / 1_000_000 ;
21+ logger .info (req .method () + " " + req .path () + " took " + durationMs + " ms" );
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments