proxy.golang.org : github.com/matttproud/httpdeadline
Package httpdeadline adds request deadline support to inbound HTTP request contexts using a microscopic http.Handler chaining middleware. This package is discussed further at https://matttproud.com/blog/posts/context-cancellation-and-server-libraries.html. Wrap the outermost http.Handler that you will register with the http.ServeMux with either FromHeader or FromQueryParams. If the /teapotz path receives a request with a HTTP header of key "X-MTP-Deadline" with a http.ParseTime-valid value, that value will be used as a deadline for the request that the teapotz handler receives. As of the implementation of this package, http.TimeFormat, time.RFC850, and time.ANSIC formats can be provided as values. Values that cannot be parsed produce http.StatusBadRequest results. The same principles described above with FromHeader apply to FromQueryParams. Consider where this package is used and whether it is in a public or private system and what sends the system requests. If it is only trusted parties sending your system requests, this package is probably safe to use. Tread carefully with public systems or with untrusted users. It is possible to perform somewhat malicious things using incorrect context deadlines (e.g., exhaust underlying backend systems by allowing them to continue for too long). Allowing the client to specify the deadline (as a literal point in time) is the only rational choice. If a client specifies a duration like five seconds, the question becomes: five seconds from when? That could be interpreted from when the request was issued or from when the request started processing. Using a literal time value is the only unambiguous and deterministic choice.
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/matttproud/httpdeadline
Keywords:
go
, go-http
, go-http-middleware
License: Apache-2.0
Latest release: about 2 months ago
Namespace: github.com/matttproud
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: about 2 months ago