header
header
ctx对象的header属性是一个Map对象,可以修改该属性来设置响应头。
server.any("/test", (ctx) => {
//设置响应头
ctx.header.set("Content-Type", "text/html; charset=utf-8");
//返回结果
ctx.body = "<h1>你好</h1>";
});
如果不设置响应头的Content-Type属性,vino会根据ctx.body的数据类型自动设置。规则如下:
