serve static assets on urls with file extension #538

Merged
bones7242 merged 19 commits from 515-showlite-serves-asset into master 2018-07-20 18:57:12 +02:00
bones7242 commented 2018-07-19 01:54:51 +02:00 (Migrated from github.com)

This PR updates the routes so that they break into two categories:

  • any route without a file extension will be a show route, meaning that this route returns an html document with meta tags, etc. These routes are 'dynamic' in that they can also serve just the asset (video or image) if the request headers indicate this. Example: spee.ch/a/apple or spee.ch/apple.
  • any route with a file extension will be a serve route, meaning the route will return the asset (video, image, etc. ) file directly. These routes are static, meaning they will return only the asset and not an html document regardless of the request headers. Examples: spee.ch/a/apple.jpg or spee.ch/apple.jpg.
This PR updates the routes so that they break into two categories: - any route without a file extension will be a `show` route, meaning that this route returns an html document with meta tags, etc. These routes are 'dynamic' in that they can also serve just the asset (video or image) if the request headers indicate this. Example: `spee.ch/a/apple` or `spee.ch/apple`. - any route with a file extension will be a `serve` route, meaning the route will return the asset (video, image, etc. ) file directly. These routes are `static`, meaning they will return only the asset and not an html document regardless of the request headers. Examples: `spee.ch/a/apple.jpg` or `spee.ch/apple.jpg`.
tzarebczan commented 2018-07-19 02:20:56 +02:00 (Migrated from github.com)

What are the headers required to serve the static content on a url without a file extention?

What are the headers required to serve the static content on a url without a file extention?
bones7242 commented 2018-07-19 17:52:38 +02:00 (Migrated from github.com)

@tzarebczan it assumes the asset is requested if the accept header includes image/ or video and not text/html. This could be added too or changed easily. Like if we want to check for the app by looking for LBRY/ in the user-agent.

const imageIsWanted = accept && accept.match(/image\/.*/) && !accept.match(/text\/html/);
const videoIsWanted = accept && accept.match(/video\/.*/) && !accept.match(/text\/html/);
@tzarebczan it assumes the asset is requested if the `accept` header includes `image/` or `video` and not `text/html`. This could be added too or changed easily. Like if we want to check for the app by looking for `LBRY/` in the `user-agent`. ``` const imageIsWanted = accept && accept.match(/image\/.*/) && !accept.match(/text\/html/); const videoIsWanted = accept && accept.match(/video\/.*/) && !accept.match(/text\/html/); ```
skhameneh (Migrated from github.com) approved these changes 2018-07-20 16:06:31 +02:00
skhameneh (Migrated from github.com) left a comment

Minor comments, nothing holding a merge back :)

Minor comments, nothing holding a merge back :)
@ -0,0 +27,4 @@
}
if (channelName) {
return "".concat(host, "/").concat(channelName, ":").concat(certificateId, "/").concat(name);
skhameneh (Migrated from github.com) commented 2018-07-20 16:04:16 +02:00

use template strings?
e.g.

return `${host}/${channelName}:${certificateId}/${name}`
use template strings? e.g. ``` return `${host}/${channelName}:${certificateId}/${name}` ```
bones7242 (Migrated from github.com) reviewed 2018-07-20 18:56:33 +02:00
@ -0,0 +27,4 @@
}
if (channelName) {
return "".concat(host, "/").concat(channelName, ":").concat(certificateId, "/").concat(name);
bones7242 (Migrated from github.com) commented 2018-07-20 18:56:33 +02:00

This is the babel transpiled code :)

This is the babel transpiled code :)
bones7242 (Migrated from github.com) reviewed 2018-07-20 18:57:08 +02:00
@ -0,0 +27,4 @@
}
if (channelName) {
return "".concat(host, "/").concat(channelName, ":").concat(certificateId, "/").concat(name);
bones7242 (Migrated from github.com) commented 2018-07-20 18:57:07 +02:00

once I merge the www.spee.ch and spee.ch repos we should be able to keep this out of version control

once I merge the www.spee.ch and spee.ch repos we should be able to keep this out of version control
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/spee.ch#538
No description provided.