当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Response.header方法代码示例

本文整理汇总了TypeScript中express.Response.header方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Response.header方法的具体用法?TypeScript Response.header怎么用?TypeScript Response.header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在express.Response的用法示例。


在下文中一共展示了Response.header方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: next

 router.use((req: Request, res: Response, next: any)=> {
   util.log(util.format("Request to: %s:%s -- Params:%s",
     req.url, req.method, JSON.stringify(req.body)));
   res.setHeader('Access-Control-Allow-Credentials', "true");
   res.header("Access-Control-Allow-Origin", req.header("Origin"));
   res.header("Access-Control-Allow-Methods", "GET,POST,PUT,HEAD,DELETE,OPTIONS");
   res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
   if ('OPTIONS' == req.method) {
     res.sendStatus(200);
   }
   else {
     next();
   }
 });
开发者ID:twicepixels,项目名称:tp-main-api,代码行数:14,代码来源:app.router.ts

示例2: injectGalleryVersion

 /**
  * This version data is mainly used on the client side to invalidate the cache
  * @param req
  * @param res
  * @param next
  */
 public static async injectGalleryVersion(req: Request, res: Response, next: NextFunction) {
   try {
     res.header(CostumHeaders.dataVersion, await ObjectManagers.getInstance().VersionManager.getDataVersion());
     next();
   } catch (err) {
     return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Can not get data version', err.toString()));
   }
 }
开发者ID:bpatrik,项目名称:PiGallery2,代码行数:14,代码来源:VersionMWs.ts

示例3: next

app.use((req: Request, res: Response, next: NextFunction) => {
  if (config.app.forceHttps === 'enabled') {
    if (!req.secure) {
      return res.redirect('https://' + req.hostname + ':' + config.app.httpsPort + req.originalUrl);
    }

    res.setHeader('Strict-Transport-Security', 'max-age=31536000');
  }

  if (req.method !== 'OPTIONS' && req.header('Accept') !== 'application/json' && req.header('Content-Type') === 'application/json') {
    return res.status(406).json({
      error: 'Unsupported "Accept" header'
    });
  }

  res.setHeader('X-Content-Type-Options', 'nosniff');
  res.setHeader('X-Frame-Options', 'deny');
  res.setHeader('Content-Security-Policy', 'default-src \'none\'');
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Authorization, Origin, X-Requested-With, Content-Type, Accept');
  return next();
});
开发者ID:Norestlabs-Mariya,项目名称:backend-ico-dashboard,代码行数:22,代码来源:app.ts

示例4: next

app.use(function(req:Request, res:Response, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});
开发者ID:shumik-vladyslav,项目名称:DigitalSignagePlayList,代码行数:5,代码来源:server.ts

示例5: nocache

    public nocache (req:Request, res:Response, next:NextFunction){
        res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate')
		res.header('Expires', '-1')
		res.header('Pragma', 'no-cache')
		next()
    }
开发者ID:Devaio,项目名称:Starter-code,代码行数:6,代码来源:middleware.ts


注:本文中的express.Response.header方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。