You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Run and RunAsync - Results<...> -> Results<..., BadRequest<ProblemDetails>>
237
-
Comprehensive set of extension methods - *WebApiEndpointRunner.Run* and *WebApiEndpointRunner.RunAsync* - to run a method that returns *Results<...>* in a sandbox. If an unhandled *exception* is thrown it will be caught and transformed it into a *BadRequest<ProblemDetails>*.
239
+
### Run and RunAsync - If your code returns an *IResult*
240
+
Comprehensive set of extension methods, to run your code in a sandbox
241
+
- If your code **does not** throw an unhandled exception, then the existing return remains the same.
242
+
- If your code **does** throw an unhandled exception, then a *BadRequest<ProblemDetails>* will be returned, with the appropriate details set on the ProblemDetails.
238
243
239
-
The *Run* and *RunAsync* methods will:
240
-
- If the method passed in **does not** throw an unhandled exception, then the existing return remains the same.
241
-
- If the method passed in **does** throw an unhandled exception, then a *BadRequest<ProblemDetails>* will be returned, with the appropriate details set on the ProblemDetails. The *error message* will be safe to return to the client, that is, it will not contain any sensitive information e.g. StackTrace.
242
-
243
-
The returned *Results<...>* type from *Run* and *RunAsync* is always augmented to additionally include *BadRequest<ProblemDetails>*
244
+
The returned *Results<...>* type is always augmented to additionally include *BadRequest<ProblemDetails>*
In this example the *Execute* method is being wrapped by the runner. It returns:
279
282
- a *NotFound* if the file does not exist
280
283
- a *FileStreamHttpResult* if the file exists
281
284
@@ -296,26 +299,24 @@ global using static Futurum.WebApiEndpoint.Micro.WebApiEndpointRunner;
296
299
297
300
This means you can use the helper functions without having to specify the namespace. As in the examples.
298
301
299
-
### Run and RunAsync - (T, Func<T, IResult>) -> Results<IResult, BadRequest<ProblemDetails>>
300
-
Extension methods - *WebApiEndpointRunner.Run* and *WebApiEndpointRunner.RunAsync* - to run a method that returns *T* in a sandbox. If an unhandled *exception* is thrown it will be caught and transformed it into a *BadRequest<ProblemDetails>*.
301
-
302
-
The *Run* and *RunAsync* methods will:
303
-
- If the method passed in **does not** throw an unhandled exception, then the *Func<T, IResult>* will be called with the return value.
304
-
- If the method passed in **does** throw an unhandled exception, then a *BadRequest<ProblemDetails>* will be returned, with the appropriate details set on the ProblemDetails. The *error message* will be safe to return to the client, that is, it will not contain any sensitive information e.g. StackTrace.
302
+
### RunToOk and RunToOkAsync - If your code returns an *T* (not a *IResult*)
303
+
Comprehensive set of extension methods, to run your code in a sandbox
304
+
- If your code **does not** throw an unhandled exception, then the existing return remains the same, *but* will be wrapped in an *Ok*.
305
+
- If your code **does** throw an unhandled exception, then a *BadRequest<ProblemDetails>* will be returned, with the appropriate details set on the ProblemDetails.
305
306
306
-
The returned *T*type from *Run* and *RunAsync* is always augmented to additionally include *BadRequest<ProblemDetails>*
307
+
The returned type from *Run* and *RunAsync* is always augmented to additionally include *BadRequest<ProblemDetails>*
For the *Func<T, IResult>*, there are a number of built-in [success helper functions](#success-helper-functions) that can be used. Or you can use your own.
0 commit comments