當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。