openshift-roadshow / nationalparks-py

Backend component to display national parks (Python).
Apache License 2.0
23 stars 1k forks source link

Trailing slashes in URLs #1

Open hroncok opened 7 years ago

hroncok commented 7 years ago

Some of the routes here use a trailing slash, such as /ws/healthz/, some don't, such as /ws/data/all. Since you are using flask, the redirect from /ws/healthz to /ws/healthz/ Just Works™, while not the other way around. Using routes with trailing slashes everywhere might be less confusing.

See the Unique URLs / Redirection Behavior in Flask Quickstart.

jorgemoralespou commented 6 years ago

@GrahamDumpleton Can you look into this?

GrahamDumpleton commented 6 years ago

I suspect we have to be careful about using/requiring trailing slashes in routes for code for those with three path elements as we need to maintain equivalence with how the Java version of the back end service worked originally.

The trailing slash redirection may well work for the back end service, but the front end client which has the path fixed, and which needs to still work with Java back end service types, possibly isn't going to handle the redirection. We can't change the front end client to use a trailing slash instead as the Java back ends can't handle trailing slash for three element path versions of URL that I remember, yet require the trailing slash for the two element path versions.

I don't know if there is a difference, but that documentation about redirection behaviour is also for Flask itself. Does that still apply for Flask-Restful, which is what we use as a layer on top?

Anyway, the important thing is we need to work the same as how Java back end services worked and they don't handle lack of trailing slashes the same.

I will leave this here to look at next time am working on the apps.