Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Session API with error handlers. #21

Open
ben-crowhurst opened this issue Jul 26, 2015 · 0 comments
Open

Extend Session API with error handlers. #21

ben-crowhurst opened this issue Jul 26, 2015 · 0 comments
Milestone

Comments

@ben-crowhurst
Copy link
Member

Brief
Give greater control over error path logic. As shown in the example below, supplying an error_handler will override any Service and/or Resource error handlers.

Example

void post_method_handler( const shared_ptr< Session >& session )
{
    const auto request = session->get_request( );

    size_t content_length = 0;
    request->get_header( "Content-Length", content_length );

    session->fetch( content_length, success_handler, error_handler );
}

int main( const int, const char** )
{
    auto resource = make_shared< Resource >( );
    resource->set_path( "/resource" );
    resource->set_method_handler( "POST", post_method_handler );

    auto settings = make_shared< Settings >( );
    settings->set_port( 1984 );
    settings->set_default_header( "Connection", "close" );

    Service service;
    service.publish( resource );
    service.start( settings );

    return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant