How to use the fdk.headers.GoLikeHeaders function in fdk

To help you get started, we’ve selected a few fdk 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 fnproject / fdk-python / fdk / json / response.py View on Github external
def __init__(self, response_data=None, headers=None, status_code=200):
        """
        JSON response object
        :param response_data: JSON response data (dict, str)
        :type response_data: object
        :param headers: JSON response HTTP headers
        :type headers: fdk.headers.GoLikeHeaders
        :param status_code: JSON response HTTP status code
        :type status_code: int
        """
        self.status_code = status_code
        self.response_data = ujson.dumps(response_data)
        self.headers = rh.GoLikeHeaders({})
        if isinstance(headers, dict):
            self.headers = rh.GoLikeHeaders(headers)
        if isinstance(headers, rh.GoLikeHeaders):
            self.headers = headers
github fnproject / fdk-python / fdk / json / handle.py View on Github external
return loop.run_until_complete(rs)
    elif isinstance(rs, str):
        hs = headers.GoLikeHeaders({})
        hs.set('content-type', 'text/plain')
        return response.RawResponse(context, response_data=rs)
    elif isinstance(rs, bytes):
        hs = headers.GoLikeHeaders({})
        hs.set('content-type', 'application/octet-stream')
        return response.RawResponse(
            context,
            response_data=rs.decode("utf8"),
            headers=hs,
            status_code=200
        )
    else:
        hs = headers.GoLikeHeaders({})
        hs.set('content-type', 'application/json')
        return response.RawResponse(
            context,
            response_data=ujson.dumps(rs),
            headers=hs,
            status_code=200,
        )