Skip to content

Instantly share code, notes, and snippets.

@bouzuya
Last active July 21, 2019 05:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bouzuya/e8523479faf52f7b5be736af4e496bdd to your computer and use it in GitHub Desktop.
Save bouzuya/e8523479faf52f7b5be736af4e496bdd to your computer and use it in GitHub Desktop.
RFC6570 - URI Template に関する覚書

RFC6570 - URI Template に関する覚書

RFC6570 の情報やそれを JavaScript から利用するための npm package についての覚書。

RFC6570 とは

RFC6570 - URI Template

URI Template は変数展開を通じて URI の範囲を示す文字列。この仕様は URI Template の構文とそのURI Template を URI 参照に展開するための処理を定義する。

URL Template とそこに埋め込まれる変数の展開 (expansion) の規則の標準化を狙いとしたもののようだ。

経緯

JSON Schema and Hyper-Schema の links に使われていることから知った。

parse

Why not use...

RFC 6570 URI Templates directly?

URI templates are designed for expanding data into a template, not matching a route. Taking an arbitrary path and matching it against a URI template isn't defined. In the expansion step of URI templates, undefined variables can be evaluated to '', which isn't useful when trying to do route matching, optional or otherwise. To use a URI-template-like language is possible, but needs to be expanded past the RFC

rcs/route-parser (npm:route-parser)の README にもあるが、template に data を展開して URI をつくる想定で定義されており、URI から template で parse して data をつくる際には不適切かもしれない。

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment