5.0 Responses
The machine answers each request with how the procedure ended, and RDCore.Web writes that as the response. Every outcome other than a returned value or none
answers with a problem details body (RFC 9457, media type application/problem+json), as ASP.NET Core writes it
(Problem details).
| Outcome | Status | Body |
|---|---|---|
| The procedure completed and returned a value | 200 OK |
The value, as JSON (§5.1). |
| The procedure completed and returned none | 204 No Content |
None. |
| A run-time error the procedure did not handle | 500 Internal Server Error |
Problem details with the error's number and code (§5.2). |
| No machine was idle in time, or the machine refused the request | 503 Service Unavailable |
Problem details (§5.3). |
| Any other outcome | 500 Internal Server Error |
Problem details (§5.3). |
A request to an endpoint that keeps machines answers 404, 409 or 503 when it reaches no machine, and 204 when the procedure ends its machine with
an End statement (§6.2).
5.1 Returned Values
Runtime Semantics
A Function or a Property Get that completes answers 200 OK, with the value it returned as the JSON body (media type application/json).
§8.1 converts the value. Empty, Null and Nothing are the body null.
A Sub that completes answers 204 No Content, with no body.
5.2 Run-time Errors
Runtime Semantics
A run-time error that the procedure does not handle answers 500 Internal Server Error with a problem details body. RDCore.Web sets these members, and
ASP.NET Core adds its own, such as type.
| Member | Value |
|---|---|
status |
500. |
title |
Run-time error 'n', where n is the error's number, in English or French by the application's UI culture. |
detail |
The error's description, as Err.Description gives it. |
errorNumber |
The error's number, as Err.Number gives it. |
errorCode |
The error's diagnostic code, such as VBR00011: VBR for one the runtime raised, VBA for one the program raised (RD-VBAL §2.6.3 Runtime Errors). |
5.3 Other Outcomes
Runtime Semantics
| Outcome | Status | title |
|---|---|---|
| No machine was idle in time (§6.1), or the machine refused the request | 503 Service Unavailable |
The machine refused the request. |
| The procedure was not found | 500 Internal Server Error |
There is no procedure Module.Procedure to invoke. |
Any other: the program had a syntax error, halted at an End statement on a machine of the pool, was interrupted, or ran code that is not implemented |
500 Internal Server Error |
The procedure Module.Procedure did not complete (Outcome). |
The title is in English or French by the application's UI culture, and the detail is the machine's explanation of the outcome.
A 503 has the header Retry-After: 1: the client may send the request again a second later.
5.4 Results
Runtime Semantics
An action answers with the Result it returns: a Function declared As RDWeb.Result returns one of the standard module RDWeb.Results. Such
an action has the program served with the RDWeb library's dispatch (§7.3), which answers it.
| Function | Status | Body |
|---|---|---|
Ok(value) |
200 OK |
The value, as JSON, or none. |
Created(location, value) |
201 Created, with the Location header |
The value, as JSON, or none. |
NoContent |
204 No Content |
None. |
BadRequest(detail) |
400 Bad Request |
Problem details, with the detail. |
Forbid |
403 Forbidden |
Problem details. |
NotFound |
404 Not Found |
Problem details. |
Redirect(url) |
302 Found, with the Location header |
None. |
Status(code, message) |
The code, from 100 to 599 | For a 4xx or a 5xx, problem details with the message as the detail. For any other code, the message as a JSON string, or none. |
Status raises error 5 for a code below 100 or above 599, which answers 500 (§5.2), and
RDW00007 reports a literal one. The problem details of a result have the status and the detail, and ASP.NET Core adds
its own members, such as title and type.
'@HttpGet("{id}/state")
Public Function State(ByVal id As Long) As RDWeb.Result
If id = 7 Then
Set State = RDWeb.Results.Status(404, "No order 7.")
Else
Set State = RDWeb.Results.Status(202, "Order " & CStr(id) & " is queued.")
End If
End Function
Implementation
| Type or member | Role |
|---|---|
MapRDWebEndpoints |
Maps each endpoint; a request to it answers as this chapter describes. |
ExecutionOutcome |
How the procedure ended, which picks the response. |
RDWebLibraryFactory |
Makes the provider that runs the calls of the RDWeb library, RDWeb.Results among them, in a runtime session. |
Tests
| Rule | Test |
|---|---|
A value is the JSON body of a 200 |
RDWebEndpointsHostingTests.TheValueAProcedureReturns_IsTheJsonBodyOfTheResponse |
A value of null is the body null |
RDWebEndpointsHostingTests.AProcedureThatReturnsNull_AnswersJsonNull |
No value answers 204 |
RDWebEndpointsHostingTests.AProcedureThatReturnsNoValue_AnswersNoContent |
A run-time error answers 500 with its number, code and description |
RDWebEndpointsHostingTests.ARunTimeError_AnswersInternalServerError_WithTheErrorsNumberAndCode |
A refused request answers 503, with when to retry |
RDWebEndpointsHostingTests.ARefusedRequest_AnswersServiceUnavailable_WithWhenToRetry |
A procedure not found, halted, or not implemented answers 500 with problem details |
RDWebEndpointsHostingTests.AProcedureThatDoesNotComplete_AnswersInternalServerError |
A 4xx or 5xx status an action returns is its status, with its message as the problem details' detail |
RDWebHostedControllerTests.AnErrorStatusAnActionReturns_IsItsStatus_WithItsMessageAsTheProblemDetailsDetail |
| Any other status an action returns is its status, with its message as the body | RDWebHostedControllerTests.AnyOtherStatusAnActionReturns_IsItsStatus_WithItsMessageAsTheBody |
| A result is answered with its status in a program with nothing else the dispatch needs | RDWebPlainControllerTests.AnErrorStatusAnActionReturns_IsItsStatus_WithItsMessageAsTheProblemDetailsDetail, RDWebPlainControllerTests.AnyOtherStatusAnActionReturns_IsItsStatus_WithItsMessageAsTheBody |
Each function of RDWeb.Results makes a result of its status, with its location, detail and body |
RDWebCallProviderTests.EachResult_HasItsStatus_AndNoLocationDetailOrBody_WhenGivenNone, RDWebCallProviderTests.ACreated_HasItsLocationAndBody_ARedirectItsLocation_AndABadRequestItsDetail, RDWebCallProviderTests.AStatus_HasItsCode_ItsMessageTheDetailOfAnErrorAndTheBodyOfAnyOther |
Status raises error 5 for a code outside 100 to 599 |
RDWebCallProviderTests.AStatusOutsideTheHttpCodes_IsError5 |
Created with no location, and Redirect with no URL, raise error 5 |
RDWebCallProviderTests.ACreatedWithNoLocation_OrARedirectWithNoUrl_IsError5 |
A literal code outside 100 to 599 is RDW00007 |
StatusCodeOutOfRangeTests.ACodeThatIsNotAnHttpStatusCode_IsReportedAsAnError_AtTheCode |