Swift Cloud
RegisterSign In
  • Welcome
  • Join the Beta
  • Platform
    • Web Assembly
    • Compute Runtime
      • Listen for Requests
      • Respond to Requests
  • Console
    • Projects
    • Deployments
    • Domains
    • Origins
    • Dictionaries
    • Metrics
    • Logs
    • Teams
    • Plans & Billing
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. Platform
  2. Compute Runtime

Listen for Requests

All Swift Cloud applications start with listening for an incoming HTTP request. This is accomplished by calling onIncomingRequest in your main handler function:

import Compute

@main
struct App {
    static func main() async throws {
        try await onIncomingRequest(handleIncomingRequest)
    }

    static func handleIncomingRequest(req: IncomingRequest, res: OutgoingResponse) async throws {
        print("Handling request:", req.url.pathname)
    }
}

PreviousCompute RuntimeNextRespond to Requests

Last updated 2 years ago

Was this helpful?