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
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
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
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
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
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
HttpGet
The member annotation that serves a procedure for the HTTP GET method: '@HttpGet("{id}").
public const string HttpGet = "HttpGet"
Field Value
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
HttpOptions
The member annotation that serves a procedure for the HTTP OPTIONS method: '@HttpOptions.
public const string HttpOptions = "HttpOptions"
Field Value
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
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
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
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
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
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
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
httpMethodstringThe HTTP method of an endpoint, as HttpMethodOf(string) gives it.
Returns
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
httpMethodstringThe HTTP method of an endpoint, as HttpMethodOf(string) gives it.
Returns
HttpMethodOf(string)
The HTTP method a member annotation serves its procedure for.
public static string? HttpMethodOf(string annotationName)
Parameters
annotationNamestringThe name of the annotation, compared without regard to case, as RD-VBA names are.
Returns
- string
GETfor HttpGet,POSTfor HttpPost,PUTfor HttpPut,PATCHfor HttpPatch,DELETEfor HttpDelete,HEADfor HttpHead andOPTIONSfor HttpOptions; null for any other annotation.