Answer1215

When you use reply method:

let resp = reply(\'hello world\')

It actually return an response object.

 

By using response object, you can modiy the response\'s status code, header, cookie, type and so on...

server.route({
  method: \'GET\',
  path: \'/\',
  handler: function(request, reply) {
    let resp = reply(\'hello world\')
    resp.code(418) // set status code to 418
    resp.type(\'text/plain\') // set type to text/plain
    resp.header(\'hello\', \'world\') // set header to hello: world
    resp.state(\'hello\', \'world\') // set cookie to hello=world
  }

 

 response object is chainable:

server.route({
   method: \'GET\',
   path: \'/\',
   handler: function(req, reply){
      reply(\'hello world\')
        .code(418)
        .type(\'text/plain\')
        .header(\'hello\', \'world\')
       -state(\'hello\', \'world\')
   }   
})  

 

分类:

技术点:

相关文章:

  • 2021-06-11
  • 2021-08-17
  • 2021-08-23
  • 2021-04-04
  • 2022-01-18
  • 2021-09-23
  • 2022-01-14
  • 2021-12-09
猜你喜欢
  • 2021-10-27
  • 2021-05-05
  • 2021-11-23
  • 2021-09-04
  • 2021-09-26
  • 2021-12-31
  • 2021-09-22
相关资源
相似解决方案