Last active
December 27, 2015 14:39
-
-
Save Fauntleroy/7342109 to your computer and use it in GitHub Desktop.
Centralized Resources plan
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
{ | |
"resources": { | |
"photos": "http://www.photos-api.com/user/12345/photos/", | |
"photos-profile": "http://www.photos-api.com/user/12345/", | |
"thing": { | |
"url": "http://www.thing-api.com/user/12345/thing/", | |
"headers": { | |
"key": "12345" | |
} | |
} | |
}, | |
"defaults": { | |
"http://www.photos-api.com/*": { | |
"headers": { | |
"key": "12345" | |
} | |
} | |
} | |
} |
Dynamic segments should work here the same way you'd expect them to normally. If you define a dynamic segment in the URL it will attempt to use dynamic data to fill in the blanks when it's used on a page.
So if I define this in the resources.json
:
{
"resources": {
"photo": "http://www.photos-api.com/user/12345/photos/{id}"
}
}
And I use it in page.hbs
:
{{!
{
"resources": {
"photo": "photo"
}
}
}}
If I go to /page?id=5
I'll be fetching http://www.photos-api.com/user/12345/photos/5
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And how do dynamic segments work?