The new decorator function.
// index.ts
import { CONNECT, Controller, ControllerBase, IHttpRequest, IHttpResponse } from '@egomobile/http-server'
@Controller()
export default class IndexController extends ControllerBase {
// can be accessed with a CONNECT request
// by using route /
@CONNECT()
async index(request: IHttpRequest, response: IHttpResponse) {
response.write('(root): ' + new Date())
}
// can be accessed with a CONNECT request
// by using route /foo
@CONNECT()
async foo(request: IHttpRequest, response: IHttpResponse) {
response.write('foo: ' + new Date())
}
// can be accessed with a CONNECT request
// by using route /baz
@CONNECT('/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 CONNECT request.