Skip to content

Expand HTTP coverage and harden response API for production use#5

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/improve-response-library
Draft

Expand HTTP coverage and harden response API for production use#5
Copilot wants to merge 3 commits intomasterfrom
copilot/improve-response-library

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 6, 2026

The library was missing common HTTP status helpers, had unexported success functions, lacked fluent header mutation, and panicked on nil writer. This fills all those gaps.

New HTTP status helpers

Client errors (errors/client.go):

  • Gone (410), UnprocessableEntity (422)

Server errors (errors/server.go):

  • NotImplemented (501), BadGateway (502), GatewayTimeout (504)

New message constants added in utils/lib.go for all of the above.

Fluent header setters on Response

SetHeader and SetHeaders added alongside the existing SetMessage/SetStatus/SetData, enabling:

gecho.Success(w).
    SetHeader("X-Request-ID", requestID).
    SetHeaders(map[string]string{"X-Version": "v1", "X-Env": "prod"}).
    SetData(payload).
    Send()

Both methods are nil-safe and fully chainable.

nil writer no longer panics

writeJSON now returns fmt.Errorf("http.ResponseWriter is nil") instead of calling panic. Middleware chains handle errors gracefully rather than crashing.

Previously unreachable exports

Accepted (202) and NoContent (204) were implemented in success/common.go but never wired into the top-level gecho package. All new error helpers are also exported from the root package.

Auto-send limitation documented

buildResponse's Send() option path cannot surface write errors without a breaking API change — this is now explicitly documented in a comment directing users to the fluent Response.Send() method when error handling matters.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Suggest enhancements for production-ready response library Suggest production-readiness improvements for gecho response library Mar 6, 2026
Copilot AI and others added 2 commits March 6, 2026 10:29
…r/SetHeaders, nil writer fix, exports

Co-authored-by: MonkyMars <155177968+MonkyMars@users.noreply.github.com>
Co-authored-by: MonkyMars <155177968+MonkyMars@users.noreply.github.com>
Copilot AI changed the title Suggest production-readiness improvements for gecho response library Expand HTTP coverage and harden response API for production use Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants