• Creates a new path validator that extracts parameters from the path and writes the data to 'params' property of request context as key/value pairs.

    Parameters

    • path: string

      The path with parameters.

    Returns HttpPathValidator

    The new path validator.

    See

    https://github.com/lukeed/regexparam

    Example

    import assert from 'assert'
    import createServer, { IHttpRequest, IHttpResponse, params } from '@egomobile/http-server'

    const app = createServer()

    app.get(params('/dirs/:dir/files/:file'), async (request: IHttpRequest, response: IHttpResponse) => {
    assert.strictEqual(typeof request.params!.dir, 'string')
    assert.strictEqual(typeof request.params!.file, 'string')
    })

    await app.listen()

Generated using TypeDoc