mardi 4 août 2015

Flask 301 redirect on some parameters

I am setting up a simple flask REST API but ran into an issue when testing where only one of my id's is causing the application to throw a 301. I can't tell why this ID is behaving differently then all the others.

object_view = ObjectView.as_view('object') #subclass of MethodView
app.add_url_rule('/objects/',  view_func=object_view, methods=['GET',])
app.add_url_rule('/objects/', view_func=object_view, methods=['POST',])
app.add_url_rule('/objects/<object_id>', view_func=object_view, methods=['GET',])

This routing code works great except when object_id is 88d63017-25ac-4c81-a637-1e6207986bc4. When I use that object_id I get a 301 and redirect to the base /objects/ list.

I tried it with trailing slashes as well and that does seem to fix it /objects/88d63017-25ac-4c81-a637-1e6207986bc4/ returns a 200 as expected but I am unsure of why this works and it breaks my conventions to do so.

Aucun commentaire:

Enregistrer un commentaire