33import org .juv25d .filter .*;
44import org .juv25d .logging .ServerLogging ;
55import org .juv25d .http .HttpParser ;
6- import org .juv25d .plugin .NotFoundPlugin ; // New import
6+ import org .juv25d .plugin .NotFoundPlugin ;
77import org .juv25d .plugin .StaticFilesPlugin ;
8- import org .juv25d .router .SimpleRouter ; // New import
8+ import org .juv25d .router .SimpleRouter ;
99import org .juv25d .util .ConfigLoader ;
1010
1111import java .util .List ;
@@ -18,42 +18,32 @@ public static void main(String[] args) {
1818 ConfigLoader config = ConfigLoader .getInstance ();
1919 Logger logger = ServerLogging .getLogger ();
2020 HttpParser httpParser = new HttpParser ();
21-
2221 Pipeline pipeline = new Pipeline ();
2322
2423 pipeline .addGlobalFilter (new SecurityHeadersFilter (), 0 );
2524
26- // Configure redirect rules
25+ pipeline .addGlobalFilter (new LoggingFilter (), 1 );
26+
27+ pipeline .addGlobalFilter (new IpFilter (Set .of (), Set .of ()), 2 );
28+
29+ if (config .isRateLimitingEnabled ()) {pipeline .addGlobalFilter (new RateLimitingFilter (
30+ config .getRequestsPerMinute (), config .getBurstCapacity ()), 3 );}
31+
2732 List <RedirectRule > redirectRules = List .of (
2833 new RedirectRule ("/old-page" , "/new-page" , 301 ),
2934 new RedirectRule ("/temp" , "https://example.com/temporary" , 302 ),
3035 new RedirectRule ("/docs/*" , "/documentation/" , 301 )
3136 );
32- pipeline .addGlobalFilter (new RedirectFilter (redirectRules ), 0 );
33-
34- // IP filter is enabled but configured with open access during development
35- // White/blacklist can be tightened when specific IP restrictions are decided
36- pipeline .addGlobalFilter (new IpFilter (
37- Set .of (),
38- Set .of ()
39- ), 0 );
4037
41- pipeline .addGlobalFilter (new LoggingFilter ( ), 0 );
38+ pipeline .addGlobalFilter (new RedirectFilter ( redirectRules ), 4 );
4239
43- if (config .isRateLimitingEnabled ()) {
44- pipeline .addGlobalFilter (new RateLimitingFilter (
45- config .getRequestsPerMinute (),
46- config .getBurstCapacity ()
47- ), 0 );
48- }
4940
50- // Initialize and configure SimpleRouter
5141 SimpleRouter router = new SimpleRouter ();
52- router .registerPlugin ("/" , new StaticFilesPlugin ()); // Register StaticFilesPlugin for the root path
53- router .registerPlugin ("/*" , new StaticFilesPlugin ()); // Register StaticFilesPlugin for all paths
54- router .registerPlugin ("/notfound" , new NotFoundPlugin ()); // Example: Register NotFoundPlugin for a specific path
42+ router .registerPlugin ("/" , new StaticFilesPlugin ());
43+ router .registerPlugin ("/*" , new StaticFilesPlugin ());
44+ router .registerPlugin ("/notfound" , new NotFoundPlugin ());
5545
56- pipeline .setRouter (router ); // Set the router in the pipeline
46+ pipeline .setRouter (router );
5747
5848 DefaultConnectionHandlerFactory handlerFactory =
5949 new DefaultConnectionHandlerFactory (httpParser , logger , pipeline );
@@ -64,7 +54,6 @@ public static void main(String[] args) {
6454 handlerFactory ,
6555 pipeline
6656 );
67-
6857 server .start ();
6958 }
7059}
0 commit comments