Skip to content

Commit

Permalink
Pass pagination header in tuple rather than in appcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Feb 24, 2019
1 parent eb045e9 commit 1e69e19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions flask_rest_api/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
from functools import wraps
import json

from werkzeug.datastructures import Headers
from flask import request, current_app

import marshmallow as ma
from webargs.flaskparser import FlaskParser

from .utils import get_appcontext, unpack_tuple_response
from .utils import unpack_tuple_response
from .compat import MARSHMALLOW_VERSION_MAJOR


Expand Down Expand Up @@ -183,7 +184,9 @@ def wrapper(*args, **kwargs):
page_header = self._make_pagination_header(
page_params.page, page_params.page_size,
page_params.item_count)
get_appcontext()['headers'][
if headers is None:
headers = Headers()
headers[
self.PAGINATION_HEADER_FIELD_NAME] = page_header

return result, status, headers
Expand Down
1 change: 0 additions & 1 deletion flask_rest_api/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def wrapper(*args, **kwargs):

# Build response
resp = jsonify(self._prepare_response_content(result_dump))
resp.headers.extend(appcontext['headers'])
set_status_and_headers_in_response(resp, status, headers)
if status is None:
resp.status_code = code
Expand Down

0 comments on commit 1e69e19

Please sign in to comment.