Functional .NET Aspire where Functional DDD and Service Level Indicators have been added.
userApi.MapPost("/register", (RegisterUserRequest request) =>
FirstName.TryCreate(request.firstName)
.Combine(LastName.TryCreate(request.lastName))
.Combine(EmailAddress.TryCreate(request.email))
.Bind((firstName, lastName, email) => User.TryCreate(firstName, lastName, email, request.password))
.ToOkResult());
RouteGroupBuilder userApi = app.MapGroup("/users")
.AddServiceLevelIndicator();
// Okay
POST {{HostAddress}}/users/register
Content-Type: application/json
Accept: application/json
{
"firstName": "Xavier",
"lastName": "John",
"email": "xa@somewhere.com",
"password": "KeepItSimple"
}
###
// Bad request
POST {{HostAddress}}/users/register
Content-Type: application/json
Accept: application/json
{
"firstName": "string",
"lastName": "",
"email": "xa.com",
"password": "string"
}
###