Crow:http请求到Rule绑定的handler_的调用链

Crow:基于req.rul查找路由Rule对象及匹配参数-CSDN博客

介绍了当接收到http请求后如何查找到Rule对象

Connection::do_read -> 
HTTPParser::feed ->
而feed实际上会依此调用定义于http_parser_settings中的所有函数,并完成http信息的解析
const static http_parser_settings settings_{
    on_message_begin,
    on_method,
    on_url,
    on_header_field,
    on_header_value,
    on_headers_complete,
    on_body,
    on_message_complete,
};

当HTTPParser::on_message_complete执行时,代表已经完成了http的解析,后续的调用链为:
HTTPParser::on_message_complete ->
HTTPParser::process_message ->  //HTTPParser通过其成员handler_指向了Connection
Connection::->handle -> //Connection通过其成员handler_指向了Crow, 并将之前查找到的路由routing_handle_result_传递给了Crow
Crow->handle(req_, res, routing_handle_result_) ->
Router::handle    //Crow通

你可能感兴趣的:(C/C++,c++)