Skip to main content

Module server

Module server 

Source
Expand description

HTTP server implementation for TAP DIDComm messages.

This module provides a complete HTTP server implementation for the Transaction Authorization Protocol (TAP). The server exposes endpoints for:

  • Processing DIDComm messages for TAP operations
  • Health checks for monitoring system availability

The server is built using the Warp web framework and provides graceful shutdown capabilities.

§Features

  • HTTP/WebSocket messaging for DIDComm transport
  • Message validation for TAP protocol compliance
  • Configurable host, port, and endpoint paths
  • Support for optional TLS encryption
  • Graceful shutdown handling
  • Health check monitoring endpoint

§Configuration

The server can be configured with the TapHttpConfig struct, which allows setting:

  • Host address and port
  • DIDComm endpoint path
  • TLS configuration (certificate and key paths)
  • Rate limiting options
  • Request timeout settings

§Example

use tap_http::{TapHttpConfig, TapHttpServer};
use tap_node::{NodeConfig, TapNode};
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a TAP Node
    let node = TapNode::new(NodeConfig::default());
     
    // Configure the HTTP server with custom settings
    let config = TapHttpConfig {
        host: "0.0.0.0".to_string(),    // Listen on all interfaces
        port: 8080,                     // Custom port
        didcomm_endpoint: "/api/didcomm".to_string(),  // Custom endpoint path
        request_timeout_secs: 60,       // 60-second timeout for outbound requests
        ..TapHttpConfig::default()
    };
     
    // Create and start the server
    let mut server = TapHttpServer::new(config, node);
    server.start().await?;
     
    // Wait for shutdown signal
    tokio::signal::ctrl_c().await?;
     
    // Gracefully stop the server
    server.stop().await?;
     
    Ok(())
}

Structs§

TapHttpServer
TAP HTTP server for handling DIDComm messages.