Interface calls the order of Tornado
initialize()
- Role: to do some initialization
prepare()
- Action: pretreatment, before performing the corresponding method invocation request
- NOTE: Any HTTP request, the method will be executed prepare
http method:
- get: high speed and efficiency, a small amount of data shortcomings unsafe
- post: request data in the request body, the amount of data, security
- put: the specified server from the client to transfer content
- delete: a request to delete the specified number of server resources
- head: Similarly get request, but no response to the specific content, the user acquires header
- patch: a request to modify the data content of local
- options: http method returns all supported url
set_default_headers()
write_error()
on_finish():
- Role: After the call request processing, release resources to clean up the process, or log processing
- NOTE: Do not try this process in response to the output
order:
- Under normal circumstances did not run out in the wrong order:
- set_default_headers: Set head
- initialize: initialize
- prepare: pretreatment (similar role django middleware)
- HTTP method (get, post ....)
- on_finish: after the end of treatment response
- Ran out of order under the exception error situation:
- set_default_headers
- initialize
- prepare
- http
- set_default_headers: this error message because the error response, you need to modify the header
- write_error: rewrite error message
- on_finish: After releasing the memory in response to do, log processing operations