• Imports one or more URL parameters into an argument / parameter of a handler as key/value pair.

    Parameters

    • Optional transformer: ParameterDataTransformer

      The custom transformer function to use.

    • Optional Rest ...names: string[]

      One or more headers to import. If the list is empty, all parameters are taken.

    Returns ParameterDecorator

    The new decorator function.

    Example

    // index.ts

    import { Controller, ControllerBase, GET, IHttpRequest, IHttpResponse, Request, Response, Url } from '@egomobile/http-server'

    interface IUrl {
    "bar": string;
    "buzz": number;
    }

    @Controller()
    export default class IndexController extends ControllerBase {
    @GET('/foo/:bar/:buzz')
    async getBar(
    @Url(({ key, source }) => {
    if (key === 'buzz') {
    return Number(source)
    }

    return source
    }, 'bar', 'buzz') importedUrl: IUrl,

    @Response() response: IHttpResponse
    ) {
    response.write(`bar: ${importedHeaders['bar']} (${typeof importedHeaders['bar']})\n`)
    response.write(`buzz: ${importedHeaders['buzz']} (${typeof importedHeaders['buzz']})\n`)
    }
    }
  • Parameters

    • Rest ...names: string[]

    Returns ParameterDecorator

Generated using TypeDoc