edge icon indicating copy to clipboard operation
edge copied to clipboard

Add `mount` method

Open i8ramin opened this issue 6 years ago • 3 comments

Allows you to mount routes to different proxied backends (supports RegExp)

Example:

import { mount, MountInfo, proxy, middleware, pipeline } from '@fly/cdn'

const routes: MountInfo[] = [
 ['/blog', proxy('https://medium.com/blog')],
 ['/docs', proxy('https://docs.example.com/docs')],
 [/^\/(?:[a-z]{2}(-[A-Z]{2})?\/)?app/, proxy('https://app.example.com')] // ie, /de-DE/products
]

const p = pipeline(middleware.httpsUpgrader, middleware.autoWebp)
const routerApp = p(mount(routes))

fly.http.respondWith(routerApp)

i8ramin avatar Apr 10 '19 14:04 i8ramin

Looks like the aws backend tests are failing for some reason. Unrelated to this change. https://dev.azure.com/flydotio/fly/_build/results?buildId=941

i8ramin avatar Apr 10 '19 14:04 i8ramin

@KittyBot, @mrkurt any ideas?

i8ramin avatar Apr 10 '19 14:04 i8ramin

Btw, this has happened before in another PR -- https://github.com/superfly/edge/pull/45#issuecomment-462967729

i8ramin avatar Apr 10 '19 14:04 i8ramin