Skip to main content

WriteStringResponse

Writes a string to the HTTP output stream.

def WriteStringResponse(
resp: http.ResponseWriter,
code: int,
body: string
) - > error

Writes a string to the HTTP output stream. This function is used to send a string as the response body to an HTTP client, setting the specified status code.

Parameters

NameTypeDescription
resphttp.ResponseWriterThe HTTP response writer to which the string body will be written. This object manages the HTTP response sent back to the client.
codeintThe HTTP status code to set for the response (e.g., 200 for OK, 404 for Not Found). This code indicates the status of the server's attempt to fulfill the request.
bodystringThe string content to be sent as the body of the HTTP response. This is the actual data returned to the client.

Returns

TypeDescription
errorAn error if the write operation fails, otherwise nil.