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

handle 406 / Accept #8

Closed
tarekziade opened this issue Dec 5, 2011 · 0 comments
Closed

handle 406 / Accept #8

tarekziade opened this issue Dec 5, 2011 · 0 comments

Comments

@tarekziade
Copy link
Contributor

# case 1 : static
@service.post(accept=('text/plain', 'application/json'))
def _service(request):
    ... if accept is in headers and not listed => 406...

# case 2: dynamic
def _get_accept(request):
     """ docstring USED by the doc"""
    ...
    return False, accepted

def _get_accept2(request):
     """ docstring USED by the doc"""
    request.validated['res'] = result
    return True, None

@service.post(accept=_get_accept)
def _service(request):
    ... the decorator calls _get_accept, and returns a 406  if False
    ... get accept can prepare something to be used by the main function to return a response (response.validated['xxx'] = xxx)
    request.response = request.validated['res']
@ghost ghost assigned almet Dec 5, 2011
almet added a commit to almet/cornice that referenced this issue Dec 6, 2011
This is to ensure that we are able to return the requested content-type.
If not, return a 406 (Not Acceptable) with the list of possibilities.

See Cornices#8 for design information
@almet almet closed this as completed Dec 6, 2011
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