Hi,
Loving learning falcon - having the source so cleanly written has been a big help.
I'm looking to implement a versioned API with falcon - either in the endpoint ("/api/1.0/foo") or as a header - but trying to work out the best way to do it, short of having a route added for each instance of each route for each version.
I looked at subclassing the router to look for the API in the uristring and switching resource function based on that, but the router only gets access to the template; not the variable, so can't utilise it.
Then i looked at middleware, but it doesn't look like you can change the resource from middleware callbacks; am i right?
What would you suggest?
API Versioning will be a awesome feature in Falcon.
+1
I'm trying to figure out how to implement versioning in a clean way and I don't find any solution...
Any ideas?
I'd like to get a better idea of how everyone envisions their resource classes being implemented to elegantly support a versioned API, and then work back from that to see what additional affordances the framework might require to support that design.
Currently, you can do some things by implementing a middleware process_request() method that rewrites the path (based on a header or incoming path) in order to influence the route (and resource) that is chosen. We can also evolve the routing components to be more flexible.
Another thing to consider is how best to support versioned media types. This probably dovetails with #145.
For a while, I did this:
import all classes and create the objetcs for the endpoints, and after, create the routes:
/v1/endpoint1
/v2/endpoint1.1
Simple, but not mutch fast.
According to various resources that I've read, the recommended way to use API versioning is through Accept Header
http://www.troyhunt.com/2014/02/your-api-versioning-is-wrong-which-is.html
http://stackoverflow.com/questions/972226/how-to-version-rest-uris
http://www.django-rest-framework.org/api-guide/versioning/
Hi ,
Is there any progress on this issue?
I like Falcon but i can't find an easy way to achieve this.
+1
API versioning in falcon would definitely be great!
@TheMushrr00m and @SyedMHashim ,
unfortunately there hasn't been much progress on this issue.
See also a more specific discussion (versioning by Accept) here: https://github.com/falconry/falcon/issues/932
As I wrote on that one, maybe we could start off with a recipe employing a custom router... It looks like the required framework building blocks were laid out here: https://github.com/falconry/falcon/pull/995
Most helpful comment
I'd like to get a better idea of how everyone envisions their resource classes being implemented to elegantly support a versioned API, and then work back from that to see what additional affordances the framework might require to support that design.
Currently, you can do some things by implementing a middleware
process_request()method that rewrites the path (based on a header or incoming path) in order to influence the route (and resource) that is chosen. We can also evolve the routing components to be more flexible.Another thing to consider is how best to support versioned media types. This probably dovetails with #145.