Esempio n. 1
0
 def _output(self, data):
     """
     JSON encode the response and set the appropriate headers
     """
     body = json.dumps(data, default=json_encoder)
     http.header('Content-Type', 'application/json')
     http.header('Content-Length', len(body))
     return body
Esempio n. 2
0
 def _output(self, data):
     """
     JSON encode the response and set the appropriate headers
     """
     body = json.dumps(data, default=json_encoder)
     http.header('Content-Type', 'application/json')
     http.header('Content-Length', len(body))
     return body
Esempio n. 3
0
 def created(self, location, data):
     """
     Return a created response.
     @type location: str
     @param location: URL of the created resource
     @type data: mapping type
     @param data: data to be returned in the body of the response
     @return: JSON encoded response
     """
     http.status_created()
     http.header('Location', location)
     return self._output(data)
Esempio n. 4
0
 def created(self, location, data):
     """
     Return a created response.
     @type location: str
     @param location: URL of the created resource
     @type data: mapping type
     @param data: data to be returned in the body of the response
     @return: JSON encoded response
     """
     http.status_created()
     http.header('Location', location)
     return self._output(data)