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
| Name | Type | Description |
|---|---|---|
| resp | http.ResponseWriter | The HTTP response writer to which the string body will be written. This object manages the HTTP response sent back to the client. |
| code | int | The 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. |
| body | string | The string content to be sent as the body of the HTTP response. This is the actual data returned to the client. |
Returns
| Type | Description |
|---|---|
error | An error if the write operation fails, otherwise nil. |