• Creates a new middleware that parses submitted cookies into 'cookies' property of request context as key/value pairs.

    Returns UniqueHttpMiddleware

    The new middleware.

    Example

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

    const app = createServer()

    // try submit 'cookie' HTTP header
    // with 'foo=bar; baz=MKTM'
    app.get('/', [cookies()], async (request: IHttpRequest, response: IHttpResponse) => {
    assert.strictEqual(request.cookies!.foo, 'bar')
    assert.strictEqual(request.cookies!.baz, 'MKTM')
    })

    await app.listen()

Generated using TypeDoc