Adds a route that matches all requests with internal error header.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Adds a route matching DELETE
HTTP method.
Either the path as a string or an object with path
, headers
and cookies
.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Adds a named destination to which you can map traffic using the traffic shaping settings in your environment in Edgio developer console
The name of the destination
A router to use when handling requests
A self-reference, suitable for chaining.
Adds a route that will run if no other routes are matched
A handler function that will be called when no other route is matched
A self-reference, suitable for chaining.
Adds a route matching GET
HTTP method.
Either the path as a string or an object with path
, headers
and cookies
.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Returns all plugins, including those registered on destination routers.
Adds a route matching HEAD
HTTP method.
Either the path as a string or an object with path
, headers
and cookies
.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Adds a route matching all methods.
Example:
new Router().match('/p/:productId', ({ cache, proxy }) => {
cache({
edge: {
maxAgeSeconds: 60 * 60 * 24
}
})
proxy("origin")
})
Either the path as a string or an object with path
, method
, and headers
.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Disables crawling of permalinks by setting the x-robots-tag: noindex
response header
for hosts matching edgio.link or edgio-perma.link.
new Router().noIndexPermalink()
Adds a route matching OPTIONS
HTTP method.
Either the path as a string or an object with path
, headers
and cookies
.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Adds a route matching PATCH
HTTP method.
Either the path as a string or an object with path
, headers
and cookies
.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Adds a route matching POST
HTTP method.
Either the path as a string or an object with path
, headers
and cookies
.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Adds preload config for router
new Router().preload(
async () => [{ path: '/foo', headers: { foo: 'bar' } }],
[{ path: '/bar' }]
)
Adds a route matching PUT
HTTP method.
Either the path as a string or an object with path
, headers
and cookies
.
A handler function that will be called when the route is matched
A self-reference, suitable for chaining.
Adds Basic Authentication.
example
router
.requireBasicAuth({ username: 'user', password: 's3cr3t!' })
// ...include additional routes below...
You can also require basic auth for a subset of URLs using the criteria
option:
router
.requireBasicAuth({ criteria: '/secret/:path*', username: 'user', password: 's3cr3t!' })
// ...include additional routes below...
The criteria option accepts a path pattern as a string, or a RouteCriteria object.
A self-reference, suitable for chaining.
Adds routes for all static assets in a directory tree.
Example
router.static('public')
To only serve files matching a particular pattern, use the glob
options:
router.static('public', {
glob: '*.css'
})
By default the path on which files are served corresponds to the path within the directory,
so for example, public/css/main.css
would be served at '/css/main.css'
,
you can override this using the path
option:
router.static('public', {
paths: file => ['/assets/ + file] // will serve public/css/main.css at /assets/css/main.css
})
You can add caching or other additional handler logic using the handler
option:
router.static('public', {
handler: (file) => ({ cache }) => {
cache({
browser: {
maxAgeSeconds: 60 * 60
},
edge: {
maxAgeSeconds: 60 * 60 * 24,
staleWhileRevalidateSeconds: 60 * 60
}
})
}
})
The path to a directory containing static assets relative to the root of your project.
A self-reference, suitable for chaining.
Returns a string summarizing all routes for debugging purposes. Don't rely on the format of this string as we may improve it over time.
Constructs plugin and pushes it to registered plugins
A plugin to use.
A self-reference, suitable for chaining.
Returns true if the request came through Edgio edge.
Notes:
x-0-version
has been injected.The request
Generated using TypeDoc
A router.