Skip to main content

serve

Attribute Macro serve 

Source
#[serve]
Expand description

Coordinate multiple protocol handlers into a single server.

§Example

use server_less::{http, ws, jsonrpc, serve};

struct MyService;

#[http]
#[ws]
#[jsonrpc]
#[serve(http, ws, jsonrpc)]
impl MyService {
    fn list_items(&self) -> Vec<String> { vec![] }
}

// Now you can:
// - service.serve("0.0.0.0:3000").await  // start server
// - service.router()                     // get combined router

§Arguments

  • http - Include the HTTP router (REST API)
  • ws - Include the WebSocket router (WS JSON-RPC)
  • jsonrpc - Include the JSON-RPC HTTP router
  • graphql - Include the GraphQL router
  • health = "/path" - Custom health check path (default: /health)