55import jakarta .servlet .http .HttpServletRequest ;
66import org .eclipse .jetty .http .HttpMethod ;
77import org .springframework .beans .factory .annotation .Autowired ;
8+ import org .springframework .context .annotation .Bean ;
9+ import org .springframework .core .io .ClassPathResource ;
810import org .springframework .http .HttpHeaders ;
911import org .springframework .http .HttpStatus ;
1012import org .springframework .http .ResponseEntity ;
1820import edu .kit .scc .dem .wapsrv .exceptions .InvalidRequestException ;
1921import edu .kit .scc .dem .wapsrv .exceptions .MethodNotAllowedException ;
2022import edu .kit .scc .dem .wapsrv .exceptions .WapException ;
23+ import org .springframework .web .servlet .function .RouterFunction ;
24+ import org .springframework .web .servlet .function .ServerResponse ;
25+
26+ import static org .springframework .web .servlet .function .RequestPredicates .path ;
27+ import static org .springframework .web .servlet .function .RouterFunctions .route ;
2128
2229/**
2330 * This controller adds the catch all feature to the server which answers all request that not mapped correctly
3037 * @version 1.1
3138 */
3239@ RestController
33- @ RequestMapping ("/" )
3440public class CatchAllController extends BasicController {
3541 @ Autowired
3642 private WapServerConfig wapServerConfig ;
3743
44+ @ Bean
45+ RouterFunction <ServerResponse > spaRouter () {
46+ ClassPathResource index = new ClassPathResource ("static/index.html" );
47+ return route ().resource (path ("/" ), index ).build ();
48+ }
49+
3850 /**
3951 * This method implements the endpoint that catches all otherwise not mapped requests to create meaningful error
4052 * messages
41- *
53+ *
4254 * @param request
4355 * The request the client sent
4456 * @param headers
@@ -47,9 +59,10 @@ public class CatchAllController extends BasicController {
4759 * @throws WapException
4860 * in case any error occurs
4961 */
50- @ RequestMapping ( value = { "/" , "/{path:[^ \\ .]*}" })
62+
5163 public ResponseEntity <?> catchallRequest (HttpServletRequest request , @ RequestHeader HttpHeaders headers )
5264 throws WapException {
65+ //TODO: should be obsolete, currently here for sake of existing tests
5366 // The basic idea is that all "real" controllers just intercept those messages
5467 // that truly fit them and check their parameters, headers and so on there.
5568 // All request that do not exactly fit one request and cannot be mapped, land here
0 commit comments