The new decorator function.
// index.ts
import { Controller, ControllerBase, IHttpRequest, IHttpResponse, OPTIONS } from '@egomobile/http-server'
@Controller()
export default class IndexController extends ControllerBase {
// can be accessed with a OPTIONS request
// by using route /
@OPTIONS()
async index(request: IHttpRequest, response: IHttpResponse) {
response.write('(root): ' + new Date())
}
// can be accessed with a OPTIONS request
// by using route /foo
@OPTIONS()
async foo(request: IHttpRequest, response: IHttpResponse) {
response.write('foo: ' + new Date())
}
// can be accessed with a OPTIONS request
// by using route /baz
@OPTIONS('/baz')
async bar(request: IHttpRequest, response: IHttpResponse) {
response.write('baz: ' + new Date())
}
}
Optional
use: Nilable<HttpMiddleware[]>Generated using TypeDoc
Add a controller method to handle a OPTIONS request.