@@ -31,6 +31,15 @@ static async Task<bool> handleJsonp(HttpContext theContext, object data)
3131
3232var app = builder . Build ( ) ;
3333
34+ app . MapFallback ( async theContext =>
35+ {
36+ theContext . Response . StatusCode = 404 ;
37+
38+ var result = new TestOutput ( false , "404 Not Found" , "" ) ;
39+
40+ await handleJsonp ( theContext , result ) ;
41+ } ) ;
42+
3443app . UseHttpLogging ( ) ;
3544
3645app . UseStaticFiles ( ) ;
@@ -49,7 +58,10 @@ static async Task<bool> handleJsonp(HttpContext theContext, object data)
4958 await handleJsonp ( theContext , statusResult ) ;
5059} ) ;
5160
52- app . MapPost ( "/test.json" , static async ( HttpContext theContext ) =>
61+ app . MapPost ( "/test.json" , RunTest ) ;
62+ app . MapGet ( "/test.json" , RunTest ) ;
63+
64+ static async Task RunTest ( HttpContext theContext )
5365{
5466 // read form variables
5567 var form = await theContext . Request . ReadFormAsync ( ) ;
@@ -59,10 +71,10 @@ static async Task<bool> handleJsonp(HttpContext theContext, object data)
5971
6072 var html = $ "{ regex } { replacement } { input . Length } { input . FirstOrDefault ( ) } ";
6173
62- var testOutput = new TestOutput ( true , html ) ;
74+ var testOutput = new TestOutput ( true , "" , html ) ;
6375
6476 await handleJsonp ( theContext , testOutput ) ;
65- } ) ;
77+ }
6678
6779var hostname = Environment . GetEnvironmentVariable ( "HOSTNAME" ) ?? "0.0.0.0" ;
6880var port = Environment . GetEnvironmentVariable ( "PORT" ) ?? "4000" ;
@@ -73,5 +85,5 @@ static async Task<bool> handleJsonp(HttpContext theContext, object data)
7385app . Run ( url ) ;
7486
7587record StatusResult ( Boolean success , string tech , string version , string timestamp , string lastmod , string commit ) ;
76- record TestOutput ( Boolean success , string html ) ;
88+ record TestOutput ( Boolean success , string message , string html ) ;
7789
0 commit comments