Skip to content

http/rs/resource

Documentation

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).

ts
path(sPath: string): void;
ParameterTypeDescription
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.

ts
method(sHttpMethod: string, oConfiguration: any): void;
ParameterTypeDescription
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".

ts
get(fServeCb: Function): ResourceMethod;
ParameterTypeDescription
fServeCbFunction

Returns

  • Type: ResourceMethod
  • Description: The ResourceMethod instance or array.

post()

Creates a handling specification for the HTTP method "POST".

ts
post(fServeCb: Function): ResourceMethod;
ParameterTypeDescription
fServeCbFunction

Returns

  • Type: ResourceMethod
  • Description: The ResourceMethod instance or array.

put()

Creates a handling specification for the HTTP method "PUT".

ts
put(fServeCb: Function): ResourceMethod;
ParameterTypeDescription
fServeCbFunction

Returns

  • Type: ResourceMethod
  • Description: The ResourceMethod instance or array.

delete()

Creates a handling specification for the HTTP method "DELETE".

ts
delete(fServeCb: Function): ResourceMethod;
ParameterTypeDescription
fServeCbFunction

Returns

  • Type: ResourceMethod
  • Description: The ResourceMethod instance or array.

remove()

Creates a handling specification for the HTTP method "DELETE" (alias for delete()).

ts
remove(fServeCb: Function): ResourceMethod;
ParameterTypeDescription
fServeCbFunction

Returns

  • Type: ResourceMethod
  • Description: The ResourceMethod instance or array.

find()

Finds a ResourceMethod with the given constraints.

ts
find(sVerb: string, arrConsumesMimeTypeStrings: any, arrProducesMimeTypeStrings: any): ResourceMethod;
ParameterTypeDescription
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.

ts
configuration(): 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.

ts
redirect(fRedirector: any): Resource;
ParameterTypeDescription
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 * *

ts
disable(sVerb: string, arrConsumesTypeStrings: any, arrProducesTypeStrings: any): Resource;
ParameterTypeDescription
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). * *

ts
readonly(): Resource;

Returns

  • Type: Resource
  • Description: The resource instance for method chaining.