Allow to have middleware for the path same with a HTML page

HTTP allows to change the type of the content to serve by Accept field in
the request. The middleware for the path same with a HTML page will
be inserted before the HTML renderer, and can take advantage of this
feature, using expressjs's "accepts" method, for example.
This commit is contained in:
Akihiko Odaki
2018-04-15 23:11:08 +09:00
parent 2758382c68
commit 917dd60cc3
5 changed files with 344 additions and 252 deletions

View File

@@ -1,7 +1,9 @@
export type Route = {
id: string;
type: 'page' | 'route';
file: string;
handlers: {
type: 'page' | 'route';
file: string;
}[];
pattern: RegExp;
test: (url: string) => boolean;
exec: (url: string) => Record<string, string>;