-
Notifications
You must be signed in to change notification settings - Fork 107
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
added support for custom response status #121
Conversation
The only downside I can see using this approach is if the return type is a tuple, this would conflict with the status format. Another way of allowing a custom status would be to create a |
I think this functionality is already present. from restless.exceptions import UnprocessableEntity
def update(self, pk):
extension_period = extension.get(action, None)
if self.extend_with(extension_period):
return {"success": True}
else:
raise UnprocessableEntity(self.message) Here is the relevant doc section: https://restless.readthedocs.io/en/latest/reference/exceptions.html?highlight=exception#module-restless.exceptions |
@sajoku Hi, thanks for the response. Yes, there are custom exceptions but this pull request allows a custom status for successful responses. |
This approach, to return a tuple with the custom successful status, might not be the best option. There could be a custom response class like
|
Ah yes I haven't had the need for this yet. Would it make sense to package this up in a status class though? (like the exceptions). from restless.response_statuses import HttpCreated
def update(self, pk):
return HttpCreated(body) Not sure about this implementation though but I think this is more like how the exceptions are also handled. |
This is a great idea, it follows the exception handling pattern. It's preferable over the tuple I think. |
This allows passing a custom status to an endpoint HTTP response by using a tuple:
Fixes #118