Skip to content
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

Support HEAD-only endpoint #630

Open
wosc opened this issue Dec 2, 2020 · 1 comment
Open

Support HEAD-only endpoint #630

wosc opened this issue Dec 2, 2020 · 1 comment

Comments

@wosc
Copy link

wosc commented Dec 2, 2020

Just like there already are endpoints for get/post/put/patch/delete that only work vor those methods, it would be helpful to have httpbin.org/head that only accepts HEAD requests. Something like this, perhaps?

@app.route("/head", methods=("HEAD",))
def view_head():
    """The request's headers
    ---
    tags:
      - HTTP Methods
    produces:
      - application/json
    responses:
      200:
        description: Echoes the request's headers as response headers (with an X-Echo- prefix).
    """

    response = jsonify(get_dict("headers"))
    for key, value in request.headers.items():
        response.headers.add('X-Echo-%s' % key, value)
    return response

The tricky part is probably how to include this new endpoint in the flasgger docs. While it's easy to enable HEAD generally, this picks it up for all endpoints that in principle allow HEAD, which are basically all that allow GET -- which creates way too much noise in the docs to be acceptable. With a quick look I could not find a way to "just include HEAD for this one endpoint", but I know basically nothing about flasgger, so I well might have missed something obvious.

-app.config["SWAGGER"] = {"title": "httpbin.org", "uiversion": 3}
+app.config["SWAGGER"] = {"title": "httpbin.org", "uiversion": 3,
+                         "ignore_verbs": ('OPTIONS',)}
@alphapapa
Copy link

Agreed, this would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants