http-server

SystemService::HttpServer

struct SystemService::HttpServer {
    const AccountNumber          service;          
    const psibase::AccountNumber commonApiService; 
    const psibase::AccountNumber homepageService;  

    sendProds(...);      
    deferReply(...);     // Indicates that the query is not expected to produce an immediate response Can be called inside `PSIBASE_SUBJECTIVE_TX`
    claimReply(...);     // Indicates that a reply will be produced by the current transaction/query/callback Can be called inside `PSIBASE_SUBJECTIVE_TX`
    sendReply(...);      // Sends a reply
    registerServer(...); // Register sender's subdomain
};

The http-server service routes HTTP requests to the appropriate service.

See C++ Web Services or Rust Web Services for more detail on routing, including how to write services which serve HTTP requests.

serve export (not an action)

This service has the following WASM exported function:

extern "C" [[clang::export_name("serve")]] void serve()

psinode calls this function on the http-server service whenever it receives an HTTP request that services may serve. This function does the actual routing. psinode has a local option (TODO: implement) which may choose an alternative routing service instead.

SystemService::HttpServer::sendProds

void SystemService::HttpServer::sendProds(
    const psibase::Action & action
);

SystemService::HttpServer::deferReply

void SystemService::HttpServer::deferReply(
    std::int32_t socket
);

Indicates that the query is not expected to produce an immediate response Can be called inside PSIBASE_SUBJECTIVE_TX.

SystemService::HttpServer::claimReply

void SystemService::HttpServer::claimReply(
    std::int32_t socket
);

Indicates that a reply will be produced by the current transaction/query/callback Can be called inside PSIBASE_SUBJECTIVE_TX.

SystemService::HttpServer::sendReply

void SystemService::HttpServer::sendReply(
    std::int32_t               socket,
    const psibase::HttpReply & response
);

Sends a reply.

SystemService::HttpServer::registerServer

void SystemService::HttpServer::registerServer(
    psibase::AccountNumber server
);

Register sender's subdomain.

When requests to a subdomain cannot be filled by 'sites', then http-server will forward the request into the serveSys action of the subdomain's registered server for it to handle the request.

Registered services may optionally:

  • Serve files via HTTP
  • Respond to RPC requests
  • Respond to GraphQL requests