[−][src]Module splinter::rest_api
Rest API Module.
Module for creating REST APIs for services.
Below is an example of a struct
that implements ResouceProvider
and then passes its resources
to a running instance of RestApi
.
use splinter::rest_api::{Resource, Method, RestApiBuilder, RestResourceProvider}; use actix_web::HttpResponse; use futures::IntoFuture; struct IndexResource { pub name: String } impl RestResourceProvider for IndexResource { fn resources(&self) -> Vec<Resource> { let name = self.name.clone(); vec![Resource::build("/index").add_method(Method::Get, move |r, p| { Box::new( HttpResponse::Ok() .body(format!("Hello, I am {}", name)) .into_future()) })] } } let index_resource = IndexResource { name: "Taco".to_string() }; RestApiBuilder::new() .add_resources(index_resource.resources()) .with_bind("localhost:8080") .build() .unwrap() .run();
Modules
cors | Provides CORS support for the REST API |
paging | |
secrets | Provides an API for managing secrets |
sessions | Provides an API for managing user sessions, including issuing and validating JWT tokens |
Structs
ErrorResponse | Model for a error response to an REST request |
EventSender | |
ProtocolVersionRangeGuard | Guards requests based on a minimum protocol version. |
Request | |
Resource |
|
Response | |
RestApi |
|
RestApiBuilder | Builder |
RestApiShutdownHandle | Shutdown handle returned by |
Enums
Continuation | A continuation indicates whether or not a guard should allow a given request to continue, or to return a result. |
Method | Rest methods compatible with |
RequestError | |
ResponseError | |
RestApiServerError | Error module for |
Traits
RequestGuard | A guard checks the request content in advance, and either continues the request, or returns a terminating result. |
RestResourceProvider | A |
Functions
get_authorization_token | |
into_bytes | |
into_protobuf | |
new_websocket_event_sender | |
percent_encode_filter_query | |
require_header |
Type Definitions
HandlerFunction |