CodeVetter · Repo Unpack · Data flow
labstack/echo
Incoming net/http requests enter a pooled Context and acquire route metadata before reaching the selected handler chain. Parsing and binding move request-controlled values into application-owned targets, while serializers and response wrappers govern output commitment. File serving reads from configured filesystems and proxying crosses an upstream network boundary. Request-local state is cleared between uses; rate-limit visitor state survives requests only within its store instance.
- ServeHTTP delegates to serveHTTPFunc; the default serveHTTP obtains a Context from sync.Pool, resets it with the incoming request/writer, resolves a handler directly or through preChain, and returns the Context to the pool after error handling.
- DefaultRouter.Route selects its matching path from URL.Path and conditionally RawPath, captures parameter values, resolves matched or fallback handlers, and writes RouteInfo, PathValues, Context.Path, and request.Pattern before returning the handler.
- QueryParam scans RawQuery without creating a map unless QueryParams has already populated the cache. It decodes percent escapes and plus signs, skips malformed or semicolon-containing pairs, and returns the first valid matching value.
- Context.Bind delegates to Echo.Binder. DefaultBinder applies path values, optionally query values for GET/DELETE/HEAD/QUERY, then Content-Type-driven body binding; later sources can overwrite earlier values, and header binding is a separate operation.
- DefaultJSONSerializer.Deserialize reads the complete body into a reset pooled buffer, calls json.Unmarshal, and retains only buffers at or below 64 KiB capacity. Status-coded read errors survive; other read or decode failures become wrapped 400 errors.
- Context.JSON installs a delayedStatusWriter around the current response and restores it afterward; serialization's first write commits the proposed status. Response then records commitment, byte count, and before/after callbacks, while the default error handler skips already committed responses.
- StaticDirectoryHandler validates request and wildcard paths before optional unescaping, checks the configured filesystem, redirects directory URLs lacking a slash, and delegates to fsFile. fsFile opens content or index.html and requires io.ReadSeeker for http.ServeContent.
- RateLimiter extracts an identifier and delegates to AllowContext when available, otherwise Allow. Its memory store updates a mutex-protected visitor map and token bucket across requests, periodically deleting stale entries; Context.Set data is separately cleared by Reset.