Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[19:57:23] SlexAxton: I have a dream about a url middleware/prefilter thing, and wanted feedback on the feasibility.
[19:57:51] SlexAxton: There are sometimes when I'd prefer a url to be displayed differently than ember likes to do it
[19:58:21] SlexAxton: One example in my app is kind of a global account setting
[19:58:25] SlexAxton: you can multiple accounts
[19:58:31] SlexAxton: and we want that reflected in the url
[19:58:45] SlexAxton:
[19:58:50] SlexAxton:
[19:59:13] SlexAxton: but really that should be a query param (foos and bars aren't 'under' the account)
[19:59:27] SlexAxton:
[19:59:49] SlexAxton: I'd love to be able to create a map for my urls onto the url that works best with ember
[20:00:19] SlexAxton: any time a url is read in by ember, or pushed out by ember, it'd go through some middleware to transform it into and out of the 'display' url
[20:00:46] SlexAxton: plausible? insane? exists already?
[20:01:53] jakemauer1: I have no idea if it's insane or not, but i'd be interested in something like that
[20:02:20] jakemauer1: we use query strings extensively in our app and it would be cool to display them in a different format
[20:03:02] jakemauer1: i think the response is probably going to be something along the lines of, "why not just adjust the API to be more restful"
[20:03:07] jakemauer1: but that is probably not an option
[20:05:27] pixelhandler: SlexAxton the is the way Ember currently setups the URL routing that does not need to match the requests to your api for entities it’s more about how the UI is mapped out, nesting and such, so it should afford whatever structure you design (around flows in your app’s UI)
[20:06:04] SlexAxton: so you think i could get something into that would more or less do what I want?
[20:06:51] pixelhandler: that is what the router is for to design around your app’s flows and use any nesting I never go more than 3 subroutes
[20:07:10] SlexAxton: so i tried that
[20:07:14] SlexAxton: let me add another example
[20:07:18] pixelhandler: I usually sketch out the screens based on user flows in the app then design the router around that
[20:07:25] SlexAxton: we have a 'live mode' and 'test mode' in our app
[20:07:36] SlexAxton: and want urls to reflect whether you're viewing live or test data
[20:07:48] SlexAxton:
[20:07:55] SlexAxton:
[20:08:08] SlexAxton: it'd be nice to not have 'live' need to be in that spot
[20:08:13] pixelhandler: ah I see how about ?mode=test
[20:08:15] SlexAxton: and just get rid of it
[20:08:26] SlexAxton: right, that's how i want ember to see it
[20:08:33] SlexAxton: but i'd rather my users see it the other way
[20:09:36] pixelhandler: seems like you could deploy a test version to /test but not so much with /account/test/
[20:11:26] SlexAxton: right, but with a prefilter, i could do like: function urlFilterIn(url) { if (url.has('/test/')) { url.remove('/test'); url.addQueryParam('mode=test'); return url; }
[20:11:34] SlexAxton: and then do the opposite
[20:11:38] SlexAxton: and all would be fine :D
[20:11:52] SlexAxton: it's like nginx/apache rewrites
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment