Expand description
§Serving
Restate services run as an HTTP endpoint.
§Creating an HTTP endpoint
- Create the endpoint
- Bind one or multiple services to it.
- Listen on the specified port (default
9080
) for connections and requests.
use restate_sdk::endpoint::Endpoint;
use restate_sdk::http_server::HttpServer;
#[tokio::main]
async fn main() {
HttpServer::new(
Endpoint::builder()
.bind(MyServiceImpl.serve())
.bind(MyVirtualObjectImpl.serve())
.bind(MyWorkflowImpl.serve())
.build(),
)
.listen_and_serve("0.0.0.0:9080".parse().unwrap())
.await;
}
§Validating request identity
SDKs can validate that incoming requests come from a particular Restate instance. You can find out more about request identity in the Security docs. Add the identity key to your endpoint as follows:
HttpServer::new(
Endpoint::builder()
.bind(MyServiceImpl.serve())
.identity_key("publickeyv1_w7YHemBctH5Ck2nQRQ47iBBqhNHy4FV7t2Usbye2A6f")
.unwrap()
.build(),
)
.listen_and_serve("0.0.0.0:9080".parse().unwrap())
.await;
Structs§
- Http
Server - Http server to expose your Restate services.