|
| 1 | +# Static Request Processing |
| 2 | + |
| 3 | +`htdocs` is just the default path of the `static.url` of a strain. you can change it if you like. but let's stick to the defaults. |
| 4 | + |
| 5 | +during `hlx publish`, the `static.url` will be added to the edge dictionaries of the VLC and will be used when looking for a resource. |
| 6 | + |
| 7 | +in general: the _path_ in a giturl acts like a _chroot_ and the requested paths will be resolved relative to it. e.g. if the giturl is `https://github.com/adobe/project-helix.io.git/docs/api` and you try to resolve `/index.html` against this strain/url, it will try to fetch `https://github.com/adobe/project-helix.io.git/docs/api/index.md`. |
| 8 | + |
| 9 | +the resolution of any request works like this: |
| 10 | + |
| 11 | +1. if the `extension` of the request path looks like an image, try to fetch the resource directly from the **content repository** |
| 12 | +2. else append `.md` to the resource path, invoke the pipeline which fetches the resource from the **content repository** |
| 13 | +3. if the response of (1) or (2) is `404`, try to fetch the original path from the **static repository**. |
| 14 | +4. if this fails, send a 404. |
| 15 | + |
| 16 | +so for example, having a strain with: |
| 17 | + |
| 18 | +```yaml |
| 19 | +strains: |
| 20 | + - name: default |
| 21 | + content: https://github.com/a/a.git/docs/api#master |
| 22 | + static: https://github.com/b/b.git/docroot#master |
| 23 | +``` |
| 24 | +
|
| 25 | +requesting `/logo.png` would try to fetch from: |
| 26 | +1. `https://raw.githubusercontent.com/a/a.git/docs/api/logo.png` |
| 27 | +2. `https://raw.githubusercontent.com/b/b.git/docroot/logo.png` (using helix--static) |
| 28 | + |
| 29 | +requesting `/index.html` would try: |
| 30 | +1. `https://adobeioruntime.net/x/x/html?repo=a&owner=a&path=/docs/api/index.md` |
| 31 | +2. `https://raw.githubusercontent.com/b/b.git/docroot/index.html` (using helix--static) |
| 32 | + |
| 33 | +requesting `/style.css` would try: |
| 34 | +1. `https://adobeioruntime.net/x/x/css?repo=a&owner=a&path=/docs/api/style.md` |
| 35 | +2. `https://raw.githubusercontent.com/b/b.git/docroot/style.css` (using `helix--static`) |
| 36 | + |
| 37 | +what is missing to solve the problem of this issue is an attempt to fetch the `css` directly from the content repository first. |
| 38 | + |
| 39 | +In general, I think that we should treat all requests the same, maybe optimize the order somehow by providing manifests for faster lookup: |
| 40 | + |
| 41 | +the order should be: **dynamic** -> **content** -> **static** |
| 42 | + |
| 43 | +i.e. |
| 44 | + |
| 45 | +1. call runtime `{extension}` action, passing the `resourcePath` and **content repository** |
| 46 | +2. if fails, try to fetch the content from the **content repository** directly (raw.githubusercontent) |
| 47 | +3. if fails, invoke `helix--static`, which tries to fetch from the **static repository** (using the `helix--static` runtime action) |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Processing of html page request |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +``` |
| 56 | +note left of agent: Index Example |
| 57 | +agent->+fastly: /index.html |
| 58 | +fastly->runtime: /<nsp>/<pkg>/html?owner=a&repo=a&path=/docs/api/index.md |
| 59 | +runtime-->*+pipeline: |
| 60 | +pipeline->github: raw.githubusercontent.com/a/a/docs/api/index.md |
| 61 | +github->pipeline: 200 |
| 62 | +pipeline-->runtime: |
| 63 | +destroy pipeline |
| 64 | +runtime->fastly: 200 |
| 65 | +fastly->agent: 200 |
| 66 | +deactivate fastly |
| 67 | + |
| 68 | +note left of agent: Logo Example |
| 69 | +agent->+fastly: /logo.png |
| 70 | +fastly->github: raw.githubusercontent.com/a/a/logo.png |
| 71 | +github->fastly: 200 |
| 72 | +fastly->agent: 200 |
| 73 | +deactivate fastly |
| 74 | +``` |
| 75 | +
|
| 76 | +## Processing of static page request |
| 77 | +
|
| 78 | + |
| 79 | +
|
| 80 | +``` |
| 81 | +participant agent |
| 82 | +participant fastly |
| 83 | +participant runtime |
| 84 | +participant helix-static |
| 85 | +note left of agent: Static Logo Example |
| 86 | +agent->+fastly: /logo.png |
| 87 | +fastly->github: raw.githubusercontent.com/a/a/logo.png |
| 88 | +github->fastly: 404 |
| 89 | +fastly->runtime: /<nsp>/helix-static?owner=b&repo=b&path=/docroot/logo.png |
| 90 | +runtime-->*+helix-static: |
| 91 | +helix-static->github: raw.githubusercontent.com/b/b/docroot/logo.png |
| 92 | +github->helix-static: 200 |
| 93 | +helix-static-->runtime: 200 |
| 94 | +destroy helix-static |
| 95 | +runtime->fastly: 200 |
| 96 | +fastly->agent: 200 |
| 97 | +deactivate fastly |
| 98 | + |
| 99 | +note left of agent: Large Static Image Example |
| 100 | +agent->+fastly: /wallpaper.png |
| 101 | +fastly->github: raw.githubusercontent.com/a/a/wallpaper.png |
| 102 | +github->fastly: 404 |
| 103 | +fastly->runtime: /<nsp>/helix-static?owner=b&repo=b&path=/docroot/wallpaper.png |
| 104 | +runtime-->*+helix-static: |
| 105 | +helix-static->github: raw.githubusercontent.com/b/b/docroot/wallpaper.png |
| 106 | +github->helix-static: 200 |
| 107 | +note over helix-static: if size is too big from action\nrespond with redirect |
| 108 | +helix-static-->runtime: 302 |
| 109 | +destroy helix-static |
| 110 | +runtime->fastly: 302; location=raw.githubusercontent.com/b/b/docroot/wallpaper.png |
| 111 | +fastly->github: raw.githubusercontent.com/b/b/docroot/wallpaper.png |
| 112 | +github->fastly: 200 |
| 113 | +fastly->agent: 200 |
| 114 | +deactivate fastly |
| 115 | + |
| 116 | +note left of agent: CSS Example |
| 117 | +agent->+fastly: /style.css |
| 118 | +fastly->runtime: /<nsp>/<pkg>/css?owner=a&repo=a&path=/docs/api/style.css |
| 119 | +runtime->fastly: 404 (no such action) |
| 120 | +fastly->runtime: /<nsp>/helix-static?owner=b&repo=b&path=/docroot/style.css |
| 121 | +runtime-->*+helix-static: |
| 122 | +helix-static->github: raw.githubusercontent.com/b/b/docroot/style.css |
| 123 | +github->helix-static: 200 |
| 124 | +helix-static-->runtime: 200 |
| 125 | +destroy helix-static |
| 126 | +runtime->fastly: 200 |
| 127 | +fastly->agent: 200 |
| 128 | +deactivate fastly |
| 129 | +``` |
| 130 | +
|
| 131 | +
|
0 commit comments