Move get_request and write_response into methods