@@ -31,6 +31,15 @@ static async Task<bool> handleJsonp(HttpContext theContext, object data)
31
31
32
32
var app = builder . Build ( ) ;
33
33
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
+
34
43
app . UseHttpLogging ( ) ;
35
44
36
45
app . UseStaticFiles ( ) ;
@@ -49,7 +58,10 @@ static async Task<bool> handleJsonp(HttpContext theContext, object data)
49
58
await handleJsonp ( theContext , statusResult ) ;
50
59
} ) ;
51
60
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 )
53
65
{
54
66
// read form variables
55
67
var form = await theContext . Request . ReadFormAsync ( ) ;
@@ -59,10 +71,10 @@ static async Task<bool> handleJsonp(HttpContext theContext, object data)
59
71
60
72
var html = $ "{ regex } { replacement } { input . Length } { input . FirstOrDefault ( ) } ";
61
73
62
- var testOutput = new TestOutput ( true , html ) ;
74
+ var testOutput = new TestOutput ( true , "" , html ) ;
63
75
64
76
await handleJsonp ( theContext , testOutput ) ;
65
- } ) ;
77
+ }
66
78
67
79
var hostname = Environment . GetEnvironmentVariable ( "HOSTNAME" ) ?? "0.0.0.0" ;
68
80
var port = Environment . GetEnvironmentVariable ( "PORT" ) ?? "4000" ;
@@ -73,5 +85,5 @@ static async Task<bool> handleJsonp(HttpContext theContext, object data)
73
85
app . Run ( url ) ;
74
86
75
87
record 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 ) ;
77
89
0 commit comments