lundi 2 février 2015

Ephermeral ember.js search resource

Context: I'm working on a blog post and tutorial that I wish existed. It's challenging because this is the first non-trivial Ember app I've made.


I've got an API that has these endpoints:



/pizzas GET
/search_pizzas POST


The organization of these endpoints can change. I know I could nest it like /pizzas/search but in this case I went with a completely separate route because it's not really related to pizzas, it's a form that is searching an external service full of all possible pizzas and this API is letting you add your favorites.


Then when you visit /pizzas again, there are your favorites.


So /pizzas is regular and it works. Because it's just a REST resource. I know the question of verbs has been asked before (Ember.js Search Model Verbs) but I'm asking about a few other things.




  1. I want to search for pizzas and return pizza. There's my local list but then there's the remote list. Or imagine a favorite car search. There's a set number of cars in a car service and the user is just doing a text search for one and then pulling back that bit of data.




  2. Should I create a controller function to handle the search? Where my world is a very clean view of a pizza resource (list, get, edit etc) but then the controller does this edge case of the external pizza, does what it needs to do but then returns back non-model data that could be used to create a pizza when the user selects favorite.




Maybe:



/pizzas
/pizzas/search (?)


I took a stab at this with ember-cli but am stuck on how to approach this compounded by ember-cli generating files that don't match the docs (for example, when someone says App.PizzaSearch =, App isn't in scope).





Aucun commentaire:

Enregistrer un commentaire