Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The addition of routes #8

Closed
josephdenne opened this issue Jan 17, 2016 · 0 comments
Closed

The addition of routes #8

josephdenne opened this issue Jan 17, 2016 · 0 comments
Assignees
Milestone

Comments

@josephdenne
Copy link
Member

The addition of a conditional routing concept to DADI CDN, whereby you can configure rules to select different recipes based on information derived about a user.

You can think of a route as a colleciton of recepes that are dynamically chosen on the basis of known data.

Recepe selection can be made on the basis of:

  • The device being used
  • Network speed
  • Current location (continent, region, country, city)
  • Language

For example: if I requested image X on an iPhone, I would receive recipe Y, but if I requested image X on a laptop I would receive recipe Z.

For device and language lookup, DADI CDN will use device sniffing of request headers. For example: https://www.npmjs.com/package/mobile-detect

For location and network lookup DADI CDN will make use of the DADI location and netspeed APIs.

Note: the DADI location API requires a clientId and secret and as such the use of location and network speed will be optional, configured within the main config file

Routes will be held in /workspace/routes as JSON files on disk, as per recipes.

Example route:

{
    "route": "thumbnail",
    "conditions": [
        {
            "condition": {
                "device": "desktop",
                "network": "broadband",
                "location": "london",
                "language": "en"
            },
            "recipe": "desktop-london-en-thumbnail-xlarge"
        },
        {
            "condition": {
                "device": "desktop",
                "network": "mobile"
            },
            "recipe": "mobile-thumbnail-xlarge"
        },
        {
            "condition": {
                "device": "mobile",
                "network": "mobile"
            },
            "recipe": "mobile-thumbnail"
        }
    ],
    "else": "thumbnail"
}

Routes will specify one or more conditions against which to match a user request, along with a recipe to load in the event of a positive match, and a fallback recipe in the event that no matches are found.

Route files will be named in the format {ROUTE-NAME}.json, where {ROUTE-NAME} is the URL string for the route and where {ROUTE-NAME} also matches the route within the JSON.

A route is called in the same way as a recipe. For example:

http://youdomain.com/example-route-name/image-filename.png

Note: routes take precedences over recepes, so in the event that there is a route called "thumbnail" and a recepe called "thumbnail", it is the route that is parsed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants