Skip to content

Commit 6f6befe

Browse files
committed
improve docs
1 parent 5b26a52 commit 6f6befe

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const (
214214
// ContextKeyHeaderAllow is set by Router for getting value for `Allow` header in later stages of handler call chain.
215215
// Allow header is mandatory for status 405 (method not found) and useful for OPTIONS method requests.
216216
// It is added to context only when Router does not find matching method handler for request.
217-
ContextKeyHeaderAllow = "____echo____header_allow"
217+
ContextKeyHeaderAllow = "echo_header_allow"
218218
)
219219

220220
const (

echo.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ const (
192192
const (
193193
HeaderAccept = "Accept"
194194
HeaderAcceptEncoding = "Accept-Encoding"
195-
// HeaderAllow is header field that lists the set of methods advertised as supported by the target resource.
196-
// Allow header is mandatory for status 405 (method not found) and useful OPTIONS method responses.
197-
// See: https://datatracker.ietf.org/doc/html/rfc7231#section-7.4.1
195+
// HeaderAllow is the name of the "Allow" header field used to list the set of methods
196+
// advertised as supported by the target resource. Returning an Allow header is mandatory
197+
// for status 405 (method not found) and useful for the OPTIONS method in responses.
198+
// See RFC 7231: https://datatracker.ietf.org/doc/html/rfc7231#section-7.4.1
198199
HeaderAllow = "Allow"
199200
HeaderAuthorization = "Authorization"
200201
HeaderContentDisposition = "Content-Disposition"
@@ -305,9 +306,8 @@ var (
305306
}
306307

307308
MethodNotAllowedHandler = func(c Context) error {
308-
// 'Allow' header RFC: https://datatracker.ietf.org/doc/html/rfc7231#section-7.4.1
309-
// >> An origin server MUST generate an Allow field in a 405 (Method Not Allowed) response
310-
// and MAY do so in any other response.
309+
// See RFC 7231 section 7.4.1: An origin server MUST generate an Allow field in a 405 (Method Not Allowed)
310+
// response and MAY do so in any other response. For disabled resources an empty Allow header may be returned
311311
routerAllowMethods, ok := c.Get(ContextKeyHeaderAllow).(string)
312312
if ok && routerAllowMethods != "" {
313313
c.Response().Header().Set(HeaderAllow, routerAllowMethods)

middleware/cors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
172172
checkPatterns := false
173173
if allowOrigin == "" {
174174
// to avoid regex cost by invalid (long) domains (253 is domain name max limit)
175-
if len(origin) <= (253+3+4) && strings.Contains(origin, "://") {
175+
if len(origin) <= (253+3+5) && strings.Contains(origin, "://") {
176176
checkPatterns = true
177177
}
178178
}

0 commit comments

Comments
 (0)