Table of Contents

Class RDWebEndpoint

Namespace
RDCore.Web.Endpoints
Assembly
RDCore.Web.dll

An endpoint of an RD-VBA application: the procedure of a controller module that serves an HTTP method on a route.

public sealed record RDWebEndpoint : IEquatable<RDWebEndpoint>
Inheritance
RDWebEndpoint
Implements
Inherited Members

Properties

BodyParameter

The parameter the request's JSON body binds to: for a POST, the one '@FromBody names, else the first parameter the route does not bind. null for a GET, and for a POST whose parameters the route binds all of.

public string? BodyParameter { get; }

Property Value

string

ContextParameters

The parameters declared As RDWeb.RequestContext, which are given the request's context, in the order Parameters declares them. Neither the route, the query string nor the body binds them.

public ImmutableArray<string> ContextParameters { get; }

Property Value

ImmutableArray<string>

ControllerDescription

The controller module's description: the text of its '@ModuleDescription annotation or of its VB_Description attribute (GetModuleDescription(ModuleParseResult)); null for a module that has none.

public string? ControllerDescription { get; init; }

Property Value

string

Description

The procedure's description: the text of its '@Description annotation or of its VB_Description attribute (GetMemberDescription(ModuleParseResult, string)); null for a procedure that has none.

public string? Description { get; init; }

Property Value

string

HttpMethod

The HTTP method the endpoint serves: GET or POST.

public string HttpMethod { get; }

Property Value

string

KeptMachineKey

The route parameter whose value is the key of the machine a request runs on, as the controller's '@KeptMachine names it; null for an endpoint whose requests run on a machine of the pool.

public string? KeptMachineKey { get; }

Property Value

string

MakesMachine

Whether a request to the endpoint makes the machine of its key before the procedure runs ('@NewMachine).

public bool MakesMachine { get; }

Property Value

bool

ModuleName

The name of the controller module.

public string ModuleName { get; }

Property Value

string

Parameters

The names of the procedure's parameters, in the order it declares them.

public ImmutableArray<string> Parameters { get; }

Property Value

ImmutableArray<string>

ProcedureName

The name of the procedure that serves the endpoint.

public string ProcedureName { get; }

Property Value

string

ReturnsResult

Whether the procedure is a Function declared As RDWeb.Result, whose status and body are the response's when the request is dispatched; any other value is a 200's body.

public bool ReturnsResult { get; init; }

Property Value

bool

ReturnsValue

Whether the procedure is a Function, whose value is the response's body; a Sub's request is answered 204.

public bool ReturnsValue { get; }

Property Value

bool

Route

The endpoint's route template, from the root of the application: /orders/{id}.

public string Route { get; }

Property Value

string

RouteParameters

The parameters the route binds, each by the name of a route parameter, in the order Parameters declares them.

public ImmutableArray<string> RouteParameters { get; }

Property Value

ImmutableArray<string>

Methods

ConventionalRouteOf(string)

The route of a controller whose '@Controller annotation writes none: its module's name, less a Controller suffix, as ASP.NET Core names a controller. ThingsController is routed under Things, which a request for /things matches, since routes match without regard to case.

public static string ConventionalRouteOf(string moduleName)

Parameters

moduleName string

The name of the controller module.

Returns

string

The name less its last ten letters when it ends with Controller, in any case, and has letters before it; the name as written otherwise.

FromAnnotation(string, string?, string, IReadOnlyList<string>, string, string?, string?, string?, bool, IReadOnlyList<string>?, bool)

The endpoint a member annotation of a controller module declares.

public static RDWebEndpoint? FromAnnotation(string moduleName, string? controllerRoute, string procedureName, IReadOnlyList<string> parameters, string annotationName, string? route, string? bodyParameter = null, string? keptMachineKey = null, bool makesMachine = false, IReadOnlyList<string>? contextParameters = null, bool returnsValue = true)

Parameters

moduleName string

The name of the controller module.

controllerRoute string

The argument of the module's '@Controller annotation; null when it writes none, which routes the controller under its conventional route (ConventionalRouteOf(string)).

procedureName string

The name of the annotated procedure.

parameters IReadOnlyList<string>

The names of the procedure's parameters, in the order it declares them.

annotationName string

The name of the member annotation.

route string

The argument of the member annotation; null when it writes none, which serves the procedure on the controller's route. A route that starts with / or ~/ is from the root of the application, and the controller's route does not prefix it.

bodyParameter string

The argument of the procedure's '@FromBody annotation: the parameter the body of a POST binds to, matched in any case, as VBA matches names. null when the procedure has none, which binds the body to the first parameter the route does not bind. A GET has no body, and binds none.

keptMachineKey string

The argument of the controller's '@KeptMachine annotation: the route parameter whose value is the key of the machine a request runs on, matched in any case. It need not be a parameter of the procedure. null for a controller without one, whose requests run on a machine of the pool.

makesMachine bool

Whether the procedure has a '@NewMachine annotation: a request makes the machine of its key.

contextParameters IReadOnlyList<string>

The parameters declared As RDWeb.RequestContext (ContextParameters), which the route, the query and the body do not bind; none when it is null.

returnsValue bool

Whether the procedure is a Function (ReturnsValue).

Returns

RDWebEndpoint

The endpoint; null when the annotation is not one of an HTTP method (HttpMethodOf(string)).

Exceptions

RDWebEndpointException

The route is not a valid route template, or it names a route parameter that is neither a parameter of the procedure nor the machine's key; for a POST, bodyParameter is not a parameter of the procedure, or is one the route binds; keptMachineKey is not a parameter of the route; or makesMachine is true and keptMachineKey is null.