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