-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
= defaultCacheControl | ||
|
||
defaultCacheControl is a function that returns a cache control header value. | ||
|
||
It's used as a callback and is the default value for the `cacheControl` option in the <<api/requestHandler,requestHandler>> function. | ||
|
||
When yielded inside the requestHandler it gets passed the found resource, it's content type and path. | ||
|
||
== Type signature | ||
|
||
See <<types#CacheControlResolver,CacheControlResolver>> | ||
|
||
== Parameters | ||
|
||
[%header,cols="1%,1%,1%,98%a"] | ||
[frame="none"] | ||
[grid="none"] | ||
|=== | ||
| Name | Type | Description | ||
| contentType | string | The content type of the resource | ||
| path | string | The path to the resource | ||
| resource | Resource | The found resource | ||
|=== | ||
|
||
See the <<../examples/singlePageReactWebapp#,SPA>> example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
= mappedRelativePath | ||
|
||
mappedRelativePath is a function that takes a `base` path string and returns a <<types#RelativePathResolver,RelativePathResolver>> function. | ||
|
||
The returned function will resolve relative paths to resources "hosted" under the based `base` path. | ||
|
||
It can be imported and used as a callback for the `relativePath` option of the <<api/requestHandler,requestHandler>> function. | ||
|
||
See the <<../examples/mapped#,mapped>> example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
= spaNotFoundHandler | ||
|
||
spaNotFoundHandler is a function that always returns a Response with the `index.html` Resource. | ||
|
||
It can be imported and used as a callback for the `notFound` option of the <<api/requestHandler,requestHandler>> function. | ||
|
||
Single page applications (SPA) typically consists of some static assets (stylesheets, fonts, images, etc...) and a single entrypoint file (e.g. `index.html`) that is responsible for routing and rendering the application. | ||
|
||
Whenever a request doesn't match a static asset, lib-static would by default return a 404 Response. | ||
|
||
This is not desireable for a SPA, because the request might be to a client-side routed page, and not a missing static asset. | ||
|
||
Such requests can happen when someone reloads or opens a bookmarked url to a client-side routed page. | ||
|
||
In addition to routing to client-side "pages", the SPA should render a beautiful 404 page, when no route matches. | ||
|
||
See the <<../examples/singlePageReactWebapp#,SPA>> example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters