Documentation Language: Swift

Method

handleRequest(uri:includeBody:)

Handles an HTTP request and returns an appropriate response.

func handleRequest(uri: String, includeBody: Bool) async -> HTTPResponse

Parameters

uri

The request URI path, potentially including query parameters.

includeBody

Whether to include the response body. Set to false for HEAD requests to omit the body while preserving headers.

Return Value

An HTTP response containing the file data or error status.

Discussion

This method processes the request URI, validates the path, locates the requested file, and constructs an HTTP response with the file content or an appropriate error status.

Response Codes

Example

let response = await handler.handleRequest(
    uri: "/documentation/index.html",
    includeBody: true
)