[][src]Crate exonum_api

High-level wrapper around a web server used by the Exonum framework.

The core APIs of this crate are designed to be reasonably independent from the web server implementation. actix is currently used as the server backend.

The wrapper is used in Rust services and in plugins for the Exonum node. The Rust runtime provides its own abstractions based on the wrapper; consult its docs for details. Node plugins use ApiBuilder directly.

Examples

Providing HTTP API for a plugin:

use exonum_api::{ApiBuilder};

#[derive(Serialize, Deserialize)]
pub struct SomeQuery {
    pub first: u64,
    pub second: u64,
}

fn create_api() -> ApiBuilder {
    let mut builder = ApiBuilder::new();
    builder
        .public_scope()
        .endpoint("some", |query: SomeQuery| async move {
            Ok(query.first + query.second)
        });
    builder
}

let builder = create_api();
// `builder` can now be passed to the node via plugin interface
// or via node channel.

Modules

backends

API backends.

Structs

ApiAggregator

Aggregator of ApiBuilders. Each builder is associated with a mount point, which is used to separate endpoints for different builders.

ApiBuilder

Exonum API builder, which is used to add endpoints to the node API.

ApiManager

Component responsible for API management. The ApiManager encapsulates endpoint handlers and is capable of updating them via UpdateEndpoints.

ApiManagerConfig

Configuration parameters for ApiManager.

ApiScope

Exonum API builder for the concrete API scope or, in other words, API access level (public or private).

Deprecated

Wrapper over an endpoint handler, which marks it as deprecated.

Error

API HTTP error struct.

ErrorBody

Body of an Error serialized into the body of erroneous server responses.

HttpStatusCode

An HTTP status code (status-code in RFC 7230 et al.).

MovedPermanentlyError

A helper structure allowing to build MovedPermanently response from the composite parts.

NamedWith

API Endpoint extractor that also contains the endpoint name and its kind.

UpdateEndpoints

Updates variable endpoints of the service, restarting all HTTP servers managed by the addressed ApiManager. The endpoints initially supplied to the ApiManager during its construction are not affected.

WebServerConfig

Configuration parameters for a single web server.

With

API endpoint handler extractor which can extract a handler from various entities.

Enums

Actuality

Endpoint actuality.

AllowOrigin

CORS header specification.

ApiAccess

Exonum API access level, either private or public.

EndpointMutability

Mutability of the endpoint. Used for auto-generated endpoints, e.g. in moved_permanently method.

Traits

ApiBackend

This trait is used to implement an API backend for Exonum.

ExtendApiBackend

API backend extender.

Type Definitions

Result

Type alias for the usual synchronous result.