http/rs/resource
Documentation
- source: http/rs/resource.ts
Overview
Classes
Resource
path()
Sets the URL path for this resource, overriding the one specified upon its construction, if a path string is provided as argument ot the method (i.e. acts as setter), or returns the path set for this resource, if the method is invoked without arguments (i.e. acts as getter).
tspath(sPath: string): void;
Parameter Type Description sPathstringThe path property to be set for this resource. Returns
- Type:
void- Description: The resource instance for method chaining (setter mode), or the path set for this resource (getter mode).
method()
Creates a new HTTP method handling specification.
tsmethod(sHttpMethod: string, oConfiguration: any): void;
Parameter Type Description sHttpMethodstringThe HTTP method (method) (e.g., "GET"). oConfigurationanyThe handler specification(s) for this HTTP method. Can be a single object or array. Returns
- Type:
void- Description: The ResourceMethod instance, or an array of ResourceMethod instances.
get()
Creates a handling specification for the HTTP method "GET".
tsget(fServeCb: Function): ResourceMethod;
Parameter Type Description fServeCbFunctionReturns
- Type:
ResourceMethod- Description: The ResourceMethod instance or array.
post()
Creates a handling specification for the HTTP method "POST".
tspost(fServeCb: Function): ResourceMethod;
Parameter Type Description fServeCbFunctionReturns
- Type:
ResourceMethod- Description: The ResourceMethod instance or array.
put()
Creates a handling specification for the HTTP method "PUT".
tsput(fServeCb: Function): ResourceMethod;
Parameter Type Description fServeCbFunctionReturns
- Type:
ResourceMethod- Description: The ResourceMethod instance or array.
delete()
Creates a handling specification for the HTTP method "DELETE".
tsdelete(fServeCb: Function): ResourceMethod;
Parameter Type Description fServeCbFunctionReturns
- Type:
ResourceMethod- Description: The ResourceMethod instance or array.
remove()
Creates a handling specification for the HTTP method "DELETE" (alias for delete()).
tsremove(fServeCb: Function): ResourceMethod;
Parameter Type Description fServeCbFunctionReturns
- Type:
ResourceMethod- Description: The ResourceMethod instance or array.
find()
Finds a ResourceMethod with the given constraints.
tsfind(sVerb: string, arrConsumesMimeTypeStrings: any, arrProducesMimeTypeStrings: any): ResourceMethod;
Parameter Type Description sVerbstringThe name of the method property of the ResourceMethod in search (e.g., "GET"). arrConsumesMimeTypeStringsanyThe consumes constraint property of the ResourceMethod in search. arrProducesMimeTypeStringsanyThe produces constraint property of the ResourceMethod in search. Returns
- Type:
ResourceMethod- Description: The found ResourceMethod instance, or undefined if not found.
configuration()
Returns the configuration of this resource.
tsconfiguration(): any;Returns
- Type:
any- Description: The resource configuration object.
redirect()
Instructs redirection of the request base don the parameter. If it is a stirng representing URI, the request will be redirected to this URI for any method. If it's a function it will be invoked and epxected to return a URI string to redirect to.
tsredirect(fRedirector: any): Resource;
Parameter Type Description fRedirectoranyThe function or string URI to redirect to.
- |
Returns
- Type:
Resource- Description: The resource instance for method chaining.
disable()
Disables the ResourceMethods that match the given constraints * *
tsdisable(sVerb: string, arrConsumesTypeStrings: any, arrProducesTypeStrings: any): Resource;
Parameter Type Description sVerbstringThe HTTP verb (e.g., "GET"). arrConsumesTypeStringsanyThe consumes constraint property of the ResourceMethod in search. arrProducesTypeStringsanyThe produces constraint property of the ResourceMethod in search.
- |
Returns
- Type:
Resource- Description: The resource instance for method chaining.
readonly()
Disables all but 'read' HTTP methods in this resource (GET, HEAD, TRACE). * *
tsreadonly(): Resource;Returns
- Type:
Resource- Description: The resource instance for method chaining.
