Repository navigation
Conversation
Several guide examples showed output that Echo v5 does not produce.
I ran each one with httptest against Echo v5.4.0 and the current
labstack/echo master, and both give the same results.
- JSONPretty output listed "email" before "name". encoding/json keeps
struct field order, so "name" comes first.
- XMLPretty output used <Name> and <Email>. The User struct has
xml:"name" and xml:"email" tags, so the elements are lowercase.
- Removed the tip about adding ?pretty to make Context#XML indent its
output. v5 has no such query parameter and the response stays on one
line.
- Removed "If the Content-Length is unknown, no after functions run".
After hooks run on every Write, with or without Content-Length.
- Binding precedence said query parameters are bound for GET / DELETE
only. DefaultBinder.Bind also binds them for HEAD and QUERY.
- The validation example claimed the response body contains the
validator message. ErrBadRequest.Wrap keeps that as the internal
error, and the default error handler sends {"message":"Bad Request"}.
The same code blocks and sentences are fixed in the es, ja, pt-br and
zh-cn pages, and the security translation baseline is updated for the
response page.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NQDmA3mwGfL83pbg9WQ6ey
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several examples in the Response, Binding and Request guides show output that Echo v5 does not produce. I ran each one with
httptestande.ServeHTTPagainst Echo v5.4.0 (the version ingo.mod) and against the current labstack/echo master. Both gave the same results.Fixes
guide/response.md). The sample listed"email"before"name".encoding/jsonkeeps struct field order, so the real output is:{ "name": "Jon", "email": "[email protected]" }guide/response.md). The sample used<Name>and<Email>. TheUserstruct in the same page hasxml:"name"andxml:"email"tags, so the real elements are<name>and<email>.?prettytip (guide/response.md). The tip saidContext#XML()indents its output when the URL has?pretty. v5 has no such check.GET /users/1?prettystill returns<User><name>Jon</name><email>[email protected]</email></User>on one line. I removed the tip.guide/response.md). The page said "If theContent-Lengthis unknown, no after functions run".Response.Writecalls the after functions on every write. The page's own/hooksexample prints "after response" with noContent-Lengthheader, and so does a handler that writes the body directly. I removed the sentence.guide/binding.md). The list said query parameters are bound for GET / DELETE only.DefaultBinder.Bindalso binds them for HEAD and QUERY. With?id=fromquery, GET, DELETE, HEAD and QUERY all set the field, while POST and PUT leave it empty.guide/request.md). The curl sample showed the validator message in the body.echo.ErrBadRequest.Wrap(err)keeps that message as the wrapped error, and the default error handler does not expose it, so the response is400 {"message":"Bad Request"}. I also checked that the validator does rejectjoe@invalid-domain, so the request does fail.The same code blocks and sentences are in the es, ja, pt-br and zh-cn pages. I applied the same change there. The code blocks are identical across locales, and the prose changes only delete a sentence or a tip, or add
HEAD / QUERYto the method list, so nothing new needed translating. I rannpm run security-translations:acceptbecauseguide/response.mdis in that list. The baseline diff only touches theguide/response.mdhashes.How I checked
github.com/labstack/echo/v5 v5.4.0andgo-playground/validator/v10. It registers each example handler and prints the response body. I ran it again with areplacepointing at labstack/echo master (7c312e0) and got the same output.node scripts/security-translation-status.mjsandnode scripts/translation-status.mjspass.node --test scripts/*.test.mjshas the same result as on master. One source-check CLI test fails on both because of my local environment (it could not write its summary file to /tmp).npm installand the full site build locally, so I did not run theplugins/*.test.mjstests that needunifiedandremark-parse. This change only edits Markdown text.