Skip to content

Commit

Permalink
Fix APIGateway documentation to include class
Browse files Browse the repository at this point in the history
That way refs to the :class: work as expected.
  • Loading branch information
jamesls committed Jun 21, 2017
1 parent 107c07e commit a234e45
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,42 +260,52 @@ for an ``@app.route(authorizer=...)`` call:
APIGateway
==========

There is a single instance of :class:`APIGateway` attached to each
:class:`Chalice` object under the ``api`` attribute.
.. class:: APIGateway()

.. attribute:: default_binary_types
This class is used to control
how API Gateway interprets ``Content-Type`` headers in both requests and
responses.

The value of ``default_binary_types`` are the ``Content-Types`` that are
considered binary by default. This value should not be changed, instead you
should modify the ``binary_types`` list to change the behavior of a content
type. Its value is: ``application/octet-stream``, ``application/x-tar``, ``application/zip``, ``audio/basic``, ``audio/ogg``, ``audio/mp4``, ``audio/mpeg``, ``audio/wav``, ``audio/webm``, ``image/png``, ``image/jpg``, ``image/gif``, ``video/ogg``, ``video/mpeg``, ``video/webm``.
There is a single instance of this class attached to each
:class:`Chalice` object under the ``api`` attribute.

.. attribute:: default_binary_types

.. attribute:: binary_types
The value of ``default_binary_types`` are the ``Content-Types`` that are
considered binary by default. This value should not be changed, instead you
should modify the ``binary_types`` list to change the behavior of a content
type. Its value is: ``application/octet-stream``, ``application/x-tar``,
``application/zip``, ``audio/basic``, ``audio/ogg``, ``audio/mp4``,
``audio/mpeg``, ``audio/wav``, ``audio/webm``, ``image/png``,
``image/jpg``, ``image/gif``, ``video/ogg``, ``video/mpeg``,
``video/webm``.

The value of ``binary_types`` controls how API Gateway interprets requests
and responses as detailed below.

If an incoming request has a ``Content-Type`` header value that is present
in the ``binary_types`` list it will be assumed that its body is a sequence
of raw bytes. You can access these bytes by accessing the
``app.current_request.raw_body`` property.
.. attribute:: binary_types

If an outgoing response from ``Chalice`` has a header ``Content-Type`` that
matches one of the ``binary_types`` its body must be a ``bytes`` type object.
It is important to note that originating request must have the ``Accept``
header for the same type as the ``Content-Type`` on the response. Otherwise
a ``400`` error will be returned.
The value of ``binary_types`` controls how API Gateway interprets requests
and responses as detailed below.

Implementation note: API Gateway and Lambda communicate through a JSON event
which is encoded using ``UTF-8``. The raw bytes are temporarily encoded
using
If an incoming request has a ``Content-Type`` header value that is present
in the ``binary_types`` list it will be assumed that its body is a sequence
of raw bytes. You can access these bytes by accessing the
``app.current_request.raw_body`` property.

base64 when being passed between API Gateway and Labmda. In the worst case
this encoding can cause the binary body to be inflated up to ``4/3`` its
original size. Lambda only accepts an event up to ``6mb``, which means even
if your binary data was not quite at that limit, with the base64 encoding it
may exceed that limit. This will manifest as a ``502`` Bad Gateway error.
If an outgoing response from ``Chalice`` has a header ``Content-Type`` that
matches one of the ``binary_types`` its body must be a ``bytes`` type object.
It is important to note that originating request must have the ``Accept``
header for the same type as the ``Content-Type`` on the response. Otherwise
a ``400`` error will be returned.

Implementation note: API Gateway and Lambda communicate through a JSON event
which is encoded using ``UTF-8``. The raw bytes are temporarily encoded
using

base64 when being passed between API Gateway and Labmda. In the worst case
this encoding can cause the binary body to be inflated up to ``4/3`` its
original size. Lambda only accepts an event up to ``6mb``, which means even
if your binary data was not quite at that limit, with the base64 encoding it
may exceed that limit. This will manifest as a ``502`` Bad Gateway error.


CORS
Expand Down

0 comments on commit a234e45

Please sign in to comment.