Optional
Rest
...names: string[]One or more headers to import. If the list is empty, all parameters are taken.
The new decorator function.
// index.ts
import { Controller, ControllerBase, GET, IHttpRequest, IHttpResponse, Query, Request, Response } from '@egomobile/http-server'
interface IQuery {
"xEgo1": string;
"xEgo2": number;
"xEgo3": boolean;
}
@Controller()
export default class IndexController extends ControllerBase {
@GET('/foo/:bar/buzz')
async getBar(
@Query(({ key, source }) => {
if (key === 'xEgo2') {
return Number(source)
} else if (key === 'xEgo3') {
return Boolean(source)
}
return source
}, 'xEgo1', 'xEgo2', 'xEgo3') importedQuery: IQuery,
@Response() response: IHttpResponse
) {
response.write(`xEgo1: ${importedQuery['xEgo1']} (${typeof importedQuery['xEgo1']})\n`)
response.write(`xEgo2: ${importedQuery['xEgo2']} (${typeof importedQuery['xEgo2']})\n`)
response.write(`xEgo3: ${importedQuery['xEgo3']} (${typeof importedQuery['xEgo3']})\n`)
}
}
Rest
...names: string[]Generated using TypeDoc
Imports one or more query parameters from URL into an argument / parameter of a handler as key/value pair.