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
WebResultEndpoints and ServiceResultEndpoints organize ASP.NET Core Minimal Apis in REPR format endpoints and are integrated with [result](https://github.com/modabas/ModResults) pattern out of box.
7
+
WebResultEndpoints and BusinessResultEndpoints organize ASP.NET Core Minimal Apis in REPR format endpoints and are integrated with [result](https://github.com/modabas/ModResults) pattern out of box.
8
8
9
9
# ModEndpoints.Core
10
10
@@ -14,7 +14,7 @@ Also contains core classes for ModEndpoints project.
14
14
15
15
## Introduction
16
16
17
-
The WebResultEndpoint and ServiceResultEndpoint abstractions are a structured approach to defining endpoints in ASP.NET Core applications. It extends the Minimal Api pattern with reusable, testable, and consistent components for request handling, validation, and response mapping.
17
+
The WebResultEndpoint and BusinessResultEndpoint abstractions are a structured approach to defining endpoints in ASP.NET Core applications. It extends the Minimal Api pattern with reusable, testable, and consistent components for request handling, validation, and response mapping.
18
18
19
19
## Key Features
20
20
@@ -280,7 +280,7 @@ See [test results](./samples/BenchmarkWebApi/BenchmarkFiles/inprocess_benchmark_
280
280
281
281
## Endpoint Types
282
282
283
-
WebResultEndpoint and ServiceResultEndpoint, the two abstract endpoint bases, have a 'HandleAsync' method which returns a strongly typed [business result](https://github.com/modabas/ModResults).
283
+
WebResultEndpoint and BusinessResultEndpoint, the two abstract endpoint bases, have a 'HandleAsync' method which returns a strongly typed [business result](https://github.com/modabas/ModResults).
284
284
285
285
These two endpoint types differ only in converting these business results into HTTP responses before sending response to client.
286
286
@@ -292,7 +292,7 @@ MinimalEndpoint within ModEndpoints.Core package, is closest to barebones Minima
292
292
293
293
Other features described previously are common for all of them.
294
294
295
-
Each type of andpoint has various implementations that accept a request model or not, that has a response model or not.
295
+
Each type of endpoint has various implementations that accept a request model or not, that has a response model or not.
296
296
297
297
### MinimalEndpoint
298
298
@@ -301,15 +301,6 @@ A MinimalEndpoint implementation, after handling request, returns the response m
301
301
- MinimalEndpoint<TRequest, TResponse>: Has a request model, supports request validation and returns a response model.
302
302
- MinimalEndpoint<TResponse>: Doesn't have a request model and returns a response model.
303
303
304
-
### ServiceResultEndpoint
305
-
306
-
A ServiceResultEndpoint implementation, after handling request, encapsulates the [business result](https://github.com/modabas/ModResults) of HandleAsync method in a HTTP 200 Minimal Api IResult and sends to client. The [business result](https://github.com/modabas/ModResults) returned may be in Ok or Failed state. This behaviour makes ServiceResultEndpoints more suitable for internal services, where clients are aware of Result or Result<TValue> implementations.
307
-
308
-
- ServiceResultEndpoint<TRequest, TResultValue>: Has a request model, supports request validation and returns a [Result<TResultValue>](https://github.com/modabas/ModResults) within HTTP 200 IResult.
309
-
- ServiceResultEndpoint<TRequest>: Has a request model, supports request validation and returns a [Result](https://github.com/modabas/ModResults) within HTTP 200 IResult.
310
-
- ServiceResultEndpointWithEmptyRequest<TResultValue>: Doesn't have a request model and returns a [Result<TResultValue>](https://github.com/modabas/ModResults) within HTTP 200 IResult.
311
-
- ServiceResultEndpointWithEmptyRequest: Doesn't have a request model and returns a [Result](https://github.com/modabas/ModResults) within HTTP 200 IResult.
312
-
313
304
### WebResultEndpoint
314
305
315
306
A WebResultEndpoint implementation, after handling request, maps the [business result](https://github.com/modabas/ModResults) of HandleAsync method to a Minimal Api IResult depending on the business result type, state and failure type (if any). Mapping behaviour can be modified or replaced with a custom one.
@@ -336,3 +327,75 @@ It is also possible to implement a custom response mapping behaviour for a WebRe
336
327
- Create an IResultToResponseMapper implementation,
337
328
- Add it to dependency injection service collection with a string key during app startup,
338
329
- Apply ResultToResponseMapper attribute to endpoint classes that will be using custom mapper. Use service registration string key as Name property of attribute.
330
+
331
+
### BusinessResultEndpoint
332
+
333
+
A BusinessResultEndpoint implementation, after handling request, encapsulates the [business result](https://github.com/modabas/ModResults) of HandleAsync method in a HTTP 200 Minimal Api IResult and sends to client. The [business result](https://github.com/modabas/ModResults) returned may be in Ok or Failed state. This behaviour makes BusinessResultEndpoints more suitable for internal services, where clients are aware of Result or Result<TValue> implementations.
334
+
335
+
- BusinessResultEndpoint<TRequest, TResultValue>: Has a request model, supports request validation and returns a [Result<TResultValue>](https://github.com/modabas/ModResults) within HTTP 200 IResult.
336
+
- BusinessResultEndpoint<TRequest>: Has a request model, supports request validation and returns a [Result](https://github.com/modabas/ModResults) within HTTP 200 IResult.
337
+
- BusinessResultEndpointWithEmptyRequest<TResultValue>: Doesn't have a request model and returns a [Result<TResultValue>](https://github.com/modabas/ModResults) within HTTP 200 IResult.
338
+
- BusinessResultEndpointWithEmptyRequest: Doesn't have a request model and returns a [Result](https://github.com/modabas/ModResults) within HTTP 200 IResult.
339
+
340
+
341
+
### ServiceEndpoint
342
+
343
+
This is a very specialized endpoint suitable for internal services. A ServiceEndpoint implementation, similar to BusinessResultEntpoint, encapsulates the response [business result](https://github.com/modabas/ModResults) of HandleAsync method in a HTTP 200 Minimal Api IResult and sends to client. The [business result](https://github.com/modabas/ModResults) returned may be in Ok or Failed state.
344
+
345
+
- ServiceEndpoint<TRequest, TResultValue>: Has a request model, supports request validation and returns a [Result<TResultValue>](https://github.com/modabas/ModResults) within HTTP 200 IResult.
346
+
- ServiceEndpoint<TRequest>: Has a request model, supports request validation and returns a [Result](https://github.com/modabas/ModResults) within HTTP 200 IResult.
347
+
348
+
A ServiceEndpoint has following special traits and constraints:
349
+
- A ServiceEndpoint is always registered with HttpMethod.Post method, and its bound pattern is determined accourding to its request type.
350
+
- A ServiceEndpoint's request must implement either IServiceRequest (for ServiceEndpoint<TRequest>) or IServiceRequest<TResultValue> (for ServiceEndpoint<TRequest, TResultValue>)
351
+
- A ServiceEndpoint's request is specific to that endpoint. Each endpoint must have its unique request type.
352
+
- To utilize the advantages of a ServiceEndpoint over other endpoint types, its request and response types has to be shared with clients and therefore has to be in a seperate class library.
353
+
354
+
These enable clients to call ServiceEndpoints by a specialized message channel resolved from dependency injection, which has to be registered at client application startup with only service base address and service request type information. No other knowledge about service or client implementation is required.
355
+
356
+
Have a look at [sample ServiceEndpoint implementations](https://github.com/modabas/ModEndpoints/tree/main/samples/ShowcaseWebApi/Features/StoresWithServiceEndpoints) along with [sample client implementation](https://github.com/modabas/ModEndpoints/tree/main/samples/Client) and [request/response model shared library](https://github.com/modabas/ModEndpoints/tree/main/samples/ShowcaseWebApi.FeatureContracts).
357
+
358
+
A client has to register remote services from requests in an assembly during application startup, which utilizes IHttpClientFactory and HttpClient underneath and can be configured similarly...
0 commit comments