Table of Contents

Class RDWebAnnotations

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

The comment annotations of RDCore.Web: the endpoints of an RD-VBA module, with '@Controller, '@KeptMachine and '@ControllerFactory on the module and the HTTP method annotations, '@FromBody and '@NewMachine on its procedures; who may reach them, with '@Authorize and '@AllowAnonymous on the module or a procedure; and the services of a program, with '@Service on a class.

public static class RDWebAnnotations
Inheritance
RDWebAnnotations
Inherited Members

Remarks

They are RD-VBA comment annotations (RD-VBAL §3.0.1.1): to MS-VBA they are comments. '@Controller, '@KeptMachine, '@ControllerFactory and '@Service are module annotations, written in the module's declarations section; the others are member annotations, written immediately above the procedure. The HTTP method annotations each take one optional string argument, their route template.

Fields

AllowAnonymous

The annotation that lets any request reach a controller or an action, signed in or not, though the controller has Authorize: '@AllowAnonymous, written in the controller's declarations section or immediately above the procedure.

public const string AllowAnonymous = "AllowAnonymous"

Field Value

string

Authorize

The annotation that lets only a signed-in user reach a controller or an action: '@Authorize or '@Authorize("Admins"), written in the controller's declarations section or immediately above the procedure. Its argument names a policy the user must meet, one that Program.Run adds; without one, any signed-in user does.

public const string Authorize = "Authorize"

Field Value

string

Controller

The module annotation that makes a module a controller: '@Controller("orders"). Its argument is the route that prefixes the routes of the module's endpoints; without one, the module's name less a Controller suffix is (ConventionalRouteOf(string)).

public const string Controller = "Controller"

Field Value

string

ControllerFactory

The module annotation that names the factory of a controller class with a default instance: '@ControllerFactory("Make"). The default instance runs the factory for each request, and the action runs on the object it returns. Without it, the factory is Create (DefaultFactory).

public const string ControllerFactory = "ControllerFactory"

Field Value

string

FromBody

The member annotation that names the parameter the request's JSON body binds to: '@FromBody("order"), written immediately above the procedure with its HTTP method annotations. It makes the binding explicit; without it, the body of a POST, a PUT or a PATCH binds to the first parameter the route does not bind, and the body of a DELETE to none. It names a parameter because a parameter list holds no comment. A GET, a HEAD and an OPTIONS bind no body.

public const string FromBody = "FromBody"

Field Value

string

HttpDelete

The member annotation that serves a procedure for the HTTP DELETE method: '@HttpDelete("{id}"). Its body binds only to the parameter FromBody names.

public const string HttpDelete = "HttpDelete"

Field Value

string

HttpGet

The member annotation that serves a procedure for the HTTP GET method: '@HttpGet("{id}").

public const string HttpGet = "HttpGet"

Field Value

string

HttpHead

The member annotation that serves a procedure for the HTTP HEAD method: '@HttpHead. The response has no body.

public const string HttpHead = "HttpHead"

Field Value

string

HttpOptions

The member annotation that serves a procedure for the HTTP OPTIONS method: '@HttpOptions.

public const string HttpOptions = "HttpOptions"

Field Value

string

HttpPatch

The member annotation that serves a procedure for the HTTP PATCH method: '@HttpPatch("{id}"). Its body binds as a POST's does.

public const string HttpPatch = "HttpPatch"

Field Value

string

HttpPost

The member annotation that serves a procedure for the HTTP POST method: '@HttpPost. The request's JSON body binds to the parameter FromBody names, else to the first parameter of the procedure that its route does not name.

public const string HttpPost = "HttpPost"

Field Value

string

HttpPut

The member annotation that serves a procedure for the HTTP PUT method: '@HttpPut("{id}"). Its body binds as a POST's does.

public const string HttpPut = "HttpPut"

Field Value

string

KeptMachine

The module annotation that keeps a machine for each value of a route parameter of a controller: '@KeptMachine("game"), written in the declarations section with '@Controller. Its argument names the route parameter whose value is the machine's key. A request to an endpoint of the controller runs on the machine of its key, which is never reset, instead of a machine of the pool (RDWebKeptMachines). The route parameter binds to the procedure's parameter of its name, when the procedure has one.

public const string KeptMachine = "KeptMachine"

Field Value

string

NewMachine

The member annotation that makes the machine of a request's key before the procedure runs on it: '@NewMachine, written immediately above the procedure with its HTTP method annotations, in a controller that has KeptMachine. A request to any other endpoint of the controller runs on the machine its key already has.

public const string NewMachine = "NewMachine"

Field Value

string

Service

The module annotation that makes a class a service of the program: '@Service, '@Service("IOrderRepository") or '@Service("IClock", "Singleton"). Its first argument is the service's name, the type a parameter declares to be given it, and the class's own name without one; its second is the service's lifetime, Scoped without one (RDWebServiceReader).

public const string Service = "Service"

Field Value

string

Methods

BindsBody(string)

Whether a request of an HTTP method binds a body at all: to the parameter FromBody names, or as BindsBodyImplicitly(string) says.

public static bool BindsBody(string httpMethod)

Parameters

httpMethod string

The HTTP method of an endpoint, as HttpMethodOf(string) gives it.

Returns

bool

true for POST, PUT, PATCH and DELETE.

BindsBodyImplicitly(string)

Whether a request of an HTTP method binds its body to the first parameter its route does not bind, when no FromBody names one.

public static bool BindsBodyImplicitly(string httpMethod)

Parameters

httpMethod string

The HTTP method of an endpoint, as HttpMethodOf(string) gives it.

Returns

bool

true for POST, PUT and PATCH.

HttpMethodOf(string)

The HTTP method a member annotation serves its procedure for.

public static string? HttpMethodOf(string annotationName)

Parameters

annotationName string

The name of the annotation, compared without regard to case, as RD-VBA names are.

Returns

string

GET for HttpGet, POST for HttpPost, PUT for HttpPut, PATCH for HttpPatch, DELETE for HttpDelete, HEAD for HttpHead and OPTIONS for HttpOptions; null for any other annotation.