4 releases (1 stable)

1.0.0 Mar 31, 2020
1.0.0-rc.3 Mar 25, 2020
1.0.0-rc.2 Mar 13, 2020
1.0.0-rc.1 Feb 7, 2020

#15 in #exonum

Download history 23/week @ 2023-12-13 32/week @ 2023-12-20 11/week @ 2023-12-27 6/week @ 2024-01-03 23/week @ 2024-01-10 16/week @ 2024-01-17 3/week @ 2024-01-24 9/week @ 2024-01-31 20/week @ 2024-02-07 31/week @ 2024-02-14 39/week @ 2024-02-21 43/week @ 2024-02-28 36/week @ 2024-03-06 32/week @ 2024-03-13 57/week @ 2024-03-20 54/week @ 2024-03-27

185 downloads per month
Used in 11 crates (6 directly)

Apache-2.0

58KB
1K SLoC

HTTP API engine for Exonum

Travis Build Status License: Apache-2.0 rust 1.42.0+ required

exonum-api crate provides an extensible interface for building backend-agnostic HTTP APIs. Within Exonum, this crate is used by Rust services and in plugins for the Exonum node.

Under the hood exonum-api uses actix.

Consult the crate docs for more details.

Examples

Providing HTTP API for a plugin:

use exonum_api::{ApiBuilder};
use serde_derive::{Deserialize, Serialize};

#[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| {
            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.

Usage

Include exonum-api as a dependency in your Cargo.toml:

[dependencies]
exonum-api = "1.0.0"

Note that the crate rarely needs to be imported directly; it is re-exported by the exonum crate.

License

exonum-api is licensed under the Apache License (Version 2.0). See LICENSE for details.

Dependencies

~28MB
~592K SLoC