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

Allow response type to be conditional based on path #204

Open
petewalker opened this issue Sep 23, 2024 · 4 comments
Open

Allow response type to be conditional based on path #204

petewalker opened this issue Sep 23, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@petewalker
Copy link

petewalker commented Sep 23, 2024

In our application, we have a mix of JSON API endpoints and HTML pages.

All of our API endpoints are prefixed with the path /api.

It would be good if we could conditionally return a JSON response for our /api endpoints and a HTML response for all others.

Is it possible to make this configurable? In the interim as workaround, I guess we could subclass your middleware?

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@petewalker petewalker added the enhancement New feature or request label Sep 23, 2024
@fabiocaccamo fabiocaccamo moved this to Todo in Open Source Sep 23, 2024
@fabiocaccamo
Copy link
Owner

@petewalker thank you for suggesting this feature, I think it could be useful to many people (me included).

@fabiocaccamo
Copy link
Owner

@petewalker I would implement this feature by allowing settings.MAINTENANCE_MODE_RESPONSE_TYPE to accept a path to a callable that will be called passing the request as argument, and it should return "html" or "json".

What you think about it? Do you have any suggestion?

@petewalker
Copy link
Author

That seems like a good first pass to me!

@violuke
Copy link

violuke commented Oct 3, 2024

This would be very helpful for us too 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

3 participants