Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 612 Bytes

README-map.md

File metadata and controls

35 lines (26 loc) · 612 Bytes

Upcache Map

Maps a request path to another request path.

Introduction

This is useful for catch-all pages.

The mapping applies after other causes of variations.

Usage

const map = require('upcache').map;
const tag = require('upcache').tag;

app.get('*', tag('app'), async (req, res, next) => {
  try {
    const html = await decideContent(req.path);
    res.send(html);
  } catch(err) {
    map(res, '/.well-known/404');
    res.send(htmlNotFound);
  }
});

http response headers

  • X-Upcache-Map contains the path to map the request path to.