How to use the apiron.endpoint.endpoint.Endpoint function in apiron

To help you get started, we’ve selected a few apiron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ithaka / apiron / src / apiron / endpoint / streaming.py View on Github external
from apiron.endpoint.endpoint import Endpoint


class StreamingEndpoint(Endpoint):
    """
    An endpoint that streams data incrementally
    """

    streaming = True

    def format_response(self, response):
        """
        Stream response in chunks

        :param requests.Response response:
            The original response from :mod:`requests`
        :return:
            The response's content
        :rtype:
            generator
github ithaka / apiron / src / apiron / endpoint / json.py View on Github external
import collections
from apiron.endpoint.endpoint import Endpoint


class JsonEndpoint(Endpoint):
    """
    An endpoint that returns :mimetype:`application/json`
    """

    def __init__(
        self, *args, path="/", default_method="GET", default_params=None, required_params=None, preserve_order=False
    ):
        super().__init__(
            path=path, default_method=default_method, default_params=default_params, required_params=required_params
        )
        self.preserve_order = preserve_order

    def format_response(self, response):
        """
        Extracts JSON data from the response