Interface: WebResource
@divine/web-service.WebResource
The instance side of a web resource.
Resources are objects that produces results based on the HTTP request method. All methods in this interface are optional. You should implement the methods that are applicable to your resource.
Implemented by
Methods
DELETE
▸ Optional DELETE(args): Promise<WebResponses>
Invoked when the client issues a DELETE request.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<WebResponses>
The response; a WebResponse object or just the response payload from which a successful WebResponse will be constructed.
Defined in
web-service/src/resource.ts:175
GET
▸ Optional GET(args): Promise<WebResponses>
Invoked when the client issues a GET request.
This method may also be invoked for HEAD requests, if HEAD is not implemented.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<WebResponses>
The response; a WebResponse object or just the response payload from which a successful WebResponse will be constructed.
Defined in
web-service/src/resource.ts:139
HEAD
▸ Optional HEAD(args): Promise<WebResponses>
Invoked when the client issues a HEAD request.
If this method is not implemented, WebService will fall back to the GET method.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<WebResponses>
The response. The response body will be discarded, but all other parts of the response applies.
Defined in
web-service/src/resource.ts:128
OPTIONS
▸ Optional OPTIONS(args): Promise<WebResponses>
Invoked when the client issues a OPTIONS request.
If this method is not implemented, WebService will use makeAllowHeader to construct a suitable response for the request.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<WebResponses>
The response; a WebResponse object or just the response payload from which a successful WebResponse will be constructed.
Defined in
web-service/src/resource.ts:187
PATCH
▸ Optional PATCH(args): Promise<WebResponses>
Invoked when the client issues a PATCH request.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<WebResponses>
The response; a WebResponse object or just the response payload from which a successful WebResponse will be constructed.
Defined in
web-service/src/resource.ts:166
POST
▸ Optional POST(args): Promise<WebResponses>
Invoked when the client issues a POST request.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<WebResponses>
The response; a WebResponse object or just the response payload from which a successful WebResponse will be constructed.
Defined in
web-service/src/resource.ts:157
PUT
▸ Optional PUT(args): Promise<WebResponses>
Invoked when the client issues a PUT request.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<WebResponses>
The response; a WebResponse object or just the response payload from which a successful WebResponse will be constructed.
Defined in
web-service/src/resource.ts:148
catch
▸ Optional catch(err): WebResponse | Promise<WebResponse>
A resource-specific error handler. Will be invoked whenever one of the other methods (expcect close) throws an exception.
Parameters
| Name | Type |
|---|---|
err | Error |
Returns
WebResponse | Promise<WebResponse>
Defined in
web-service/src/resource.ts:209
close
▸ Optional close(): Promise<void>
Invoked when the request has been fully processed. Useful for clean-up tasks.
Returns
Promise<void>
Defined in
web-service/src/resource.ts:118
default
▸ Optional default(args): Promise<WebResponses>
Invoked when the client issues any request that was not handled by HEAD, GET, PUT, POST, PATCH, DELETE or OPTIONS.
Can be used to handle multiple verbs with the same code or to handle custom verbs not defined by this interface.
Note that automatic OPTIONS handling will not work as desired when this method is used, since there is no way
for WebService to figure out what methods are supported.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<WebResponses>
The response; a WebResponse object or just the response payload from which a successful WebResponse will be constructed.
Defined in
web-service/src/resource.ts:201
init
▸ Optional init(args): Promise<void>
Initializes the resource object. This method acts like an asynchronous constructor.
Parameters
| Name | Type | Description |
|---|---|---|
args | WebArguments | The request arguments. |
Returns
Promise<void>