11using System . Text ;
2+ using System . Text . Json ;
23using FluentMinimalApiMapper ;
34using Microsoft . AspNetCore . Mvc ;
45
@@ -83,7 +84,7 @@ public void AddRoutes(IEndpointRouteBuilder app)
8384 } ) ;
8485
8586 grp . MapGet ( "/no-content-type" ,
86- async ( HttpContext ctx ) =>
87+ async ctx =>
8788 {
8889 await ctx . Response . Body . WriteAsync ( Encoding . UTF8 . GetBytes ( "raw body with no content-type" ) ) ;
8990 } ) ;
@@ -104,23 +105,27 @@ public void AddRoutes(IEndpointRouteBuilder app)
104105 ( ) =>
105106 {
106107 var sb = new StringBuilder ( ) ;
107- for ( var i = 0 ; i < 20_000 ; i ++ ) sb . Append ( 'x' ) ;
108+ for ( var i = 0 ; i < 20_000 ; i ++ )
109+ {
110+ sb . Append ( 'x' ) ;
111+ }
112+
108113 return Results . Text ( sb . ToString ( ) , "text/plain" , Encoding . UTF8 ) ;
109114 } ) ;
110115
111116 grp . MapPost ( "/echo-with-headers" ,
112- ( [ FromBody ] SharedKernel . Demo . TestTypes payload , HttpResponse res ) =>
117+ ( [ FromBody ] TestTypes payload , HttpResponse res ) =>
113118 {
114119 res . Headers [ "Custom-Header-Response" ] = "CustomValue" ;
115120 res . ContentType = "application/json; charset=utf-8" ;
116121 return Results . Json ( payload ) ;
117122 } ) ;
118123
119124 grp . MapGet ( "/ping" , ( ) => Results . Text ( "pong" , "text/plain" ) ) ;
120-
125+
121126
122127 grp . MapGet ( "/invalid-json" ,
123- async ( HttpContext ctx ) =>
128+ async ctx =>
124129 {
125130 ctx . Response . StatusCode = StatusCodes . Status200OK ;
126131 ctx . Response . ContentType = "application/json" ;
@@ -134,27 +139,31 @@ public void AddRoutes(IEndpointRouteBuilder app)
134139 var httpClient = httpClientFactory . CreateClient ( "RandomApiClient" ) ;
135140 httpClient . DefaultRequestHeaders . Add ( "auth" , "hardcoded-auth-value" ) ;
136141
137- var body = new SharedKernel . Demo . TestTypes
142+ var body = new TestTypes
138143 {
139144 AnimalType = AnimalType . Cat ,
140145 JustText = "Hello from Get Data" ,
141146 JustNumber = 100
142147 } ;
143148
144- var content = new StringContent ( System . Text . Json . JsonSerializer . Serialize ( body ) ,
145- System . Text . Encoding . UTF8 ,
149+ var content = new StringContent ( JsonSerializer . Serialize ( body ) ,
150+ Encoding . UTF8 ,
146151 "application/json" ) ;
147152
148153 var response = await httpClient . PostAsync ( "tests/echo-with-headers?barev=5" , content ) ;
149154
150155 if ( ! response . IsSuccessStatusCode )
156+ {
151157 throw new Exception ( "Something went wrong" ) ;
158+ }
152159
153160 var responseBody = await response . Content . ReadAsStringAsync ( ) ;
154- var testTypes = System . Text . Json . JsonSerializer . Deserialize < SharedKernel . Demo . TestTypes > ( responseBody ) ;
161+ var testTypes = JsonSerializer . Deserialize < TestTypes > ( responseBody ) ;
155162
156163 if ( testTypes == null )
164+ {
157165 throw new Exception ( "Failed to get data from external API" ) ;
166+ }
158167
159168 return TypedResults . Ok ( testTypes ) ;
160169 } ) ;
0 commit comments