MCPcopy
hub / github.com/hapijs/hapi / handler

Function handler

test/response.js:30–47  ·  view source on GitHub ↗
(request, h)

Source from the content-addressed store, hash-verified

28 it('returns a response', async () => {
29
30 const handler = (request, h) => {
31
32 return h.response('text')
33 .type('text/plain')
34 .charset('ISO-8859-1')
35 .ttl(1000)
36 .header('set-cookie', 'abc=123')
37 .state('sid', 'abcdefg123456')
38 .state('other', 'something', { isSecure: true })
39 .unstate('x')
40 .header('Content-Type', 'text/plain; something=something')
41 .header('vary', 'x-control')
42 .header('combo', 'o')
43 .header('combo', 'k', { append: true, separator: '-' })
44 .header('combo', 'bad', { override: false })
45 .code(200)
46 .message('Super');
47 };
48
49 const server = Hapi.server({ compression: { minBytes: 1 } });
50 server.route({ method: 'GET', path: '/', options: { handler, cache: { expiresIn: 9999 } } });

Callers

nothing calls this directly

Calls 15

passThroughMethod · 0.80
escapeMethod · 0.80
messageMethod · 0.65
codeMethod · 0.65
headerMethod · 0.65
unstateMethod · 0.65
stateMethod · 0.65
ttlMethod · 0.65
charsetMethod · 0.65
typeMethod · 0.65
responseMethod · 0.65
createdMethod · 0.65

Tested by

no test coverage detected