Ejemplo n.º 1
0
    def load(self, store: frozendict):
        if self.status is None:
            self.status = store.get(self.status_field, 200)

        return make_response(store.get(self.data_field),
                             status=self.status,
                             headers=self.headers)
Ejemplo n.º 2
0
    def run_pipe(self) -> frozendict:
        """The main method.
        Takes data and pass through pipe. Handles request and response

        :raises: PipeException
        """
        pipe_to_run = self.pipe_schema.get(self.request.method, None)

        if pipe_to_run is None:
            return make_response('method isn\'t supported', status=400)

        self._run_pipe(pipe_to_run.get('in', ()))
        return self._run_pipe(pipe_to_run.get('out', ()))
Ejemplo n.º 3
0
 def load(self, store: frozendict):
     return make_response(f'bad request: {store.get("exception")}',
                          status=400)
Ejemplo n.º 4
0
 def load(self, store: frozendict):
     return make_response(f'unauthorized: {store.get("exception")}',
                          status=401)
Ejemplo n.º 5
0
 def load(self, store: frozendict):
     return make_response(f'server error: {store.get("exception")}',
                          status=500)
Ejemplo n.º 6
0
 def load(self, store: frozendict):
     return make_response(f'object not found: {store.get("exception")}',
                          status=404)
Ejemplo n.º 7
0
 def load(self, store: frozendict):
     return make_response(store.get(self.data_field),
                          is_json=True,
                          status=self.status)