HTTPContext
Response
Set status, headers, cookies, redirects, and direct writer output.
ServerResponse buffers status and headers until the response is committed.
func (c *UploadController) accepted(ctx *http.Context) error {
ctx.Response().SetStatus(http.StatusAccepted)
ctx.Response().SetHeader("X-Request-ID", requestID)
ctx.Response().AddCookie(sessionCookie)
return nil
}If you write directly to Response().Writer(), the response is committed and
later status/header changes may no longer apply.
func (c *DownloadController) download(ctx *http.Context) error {
ctx.Response().SetHeader("Content-Type", "text/plain")
_, err := io.WriteString(ctx.Response().Writer(), "report")
return err
}Use direct writer access for streaming or custom response formats. Use
http.Result for normal structured responses.
