-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make API discoverable from the root #705
Conversation
680f2ba
to
7253711
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work :)
I have one question and then it is good to go ^^
openfisca_web_api_preview/app.py
Outdated
@@ -81,6 +98,8 @@ def get_variable(id): | |||
|
|||
@app.route('/spec') | |||
def get_spec(): | |||
if data['host'] is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is checked in def resolve_host
. Isn't it redundant to have it here also ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec
route can be called before the /
one. In that case, data['host']
is still None
when we get here, so we need to resolve the host.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I was just told that re-using the host from one request to another was risky (one local request, and everyone is seeing a localhost:3000
as a host) and not very stateless, so we need a different approach 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, adapted the code :)
c44c789
to
d015204
Compare
Connected to #615
/
instead of a 404 error.For instance,
curl -i localhost:5000
gives:If the Web API is started with
openfisca serve -p 3000 --welcome-message "Welcome to the OpenFisca-France Web API. To learn how to use it, check our interactive swagger documentation: https://fr.openfisca.org/legislation/swagger."
Then
curl -i localhost:5000
gives:(Like other configuration variables, this custom message can also be defined in a configuration file. Check the openfisca serve documentation)