For the complete documentation index, see llms.txt. This page is also available as Markdown.

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)
    }
}

Last updated

Was this helpful?