Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RosettaIDFromContext ¶
func RosettaIDFromRequest ¶
Types ¶
type HeaderForwarder ¶
type HeaderForwarder struct {
// contains filtered or unexported fields
}
HeaderExtractingTransport is a utility to help a rosetta server forward headers to and from native node requests. It implements several interfaces to achieve that:
- http.RoundTripper: this can be used to create an http Client that will automatically save headers if necessary
- func(http.Handler) http.Handler: this can be used to wrap an http.Handler to set headers on the response
the headers can be requested later.
TODO: this should expire entries after a certain amount of time
func NewHeaderForwarder ¶
func NewHeaderForwarder(interestingHeaders []string, transport http.RoundTripper) *HeaderForwarder
func (*HeaderForwarder) HeaderForwarderHandler ¶
func (hf *HeaderForwarder) HeaderForwarderHandler(next http.Handler) http.Handler
HeaderForwarderHandler will allow the next handler to serve the request, and then checks if there are any native node response headers recorded for the request. If there are, it will set those headers on the response
func (*HeaderForwarder) RoundTrip ¶
RoundTrip implements http.RoundTripper and will be used to construct an http Client which saves the native node response headers if necessary.
func (*HeaderForwarder) WithRequestID ¶
func (hf *HeaderForwarder) WithRequestID(req *http.Request) *http.Request
WithRequestID adds a unique ID to the request context. A new request is returned that contains the new context
type ResponseWriter ¶
type ResponseWriter struct {
RosettaRequestID string
GetAdditionalHeaders func(string) (http.Header, bool)
// contains filtered or unexported fields
}
ResponseWriter is a wrapper around a http.ResponseWriter that allows us to set headers just before the WriteHeader function is called. These headers will be extracted from native node responses, and set on the rosetta response.
func NewResponseWriter ¶
func NewResponseWriter( writer http.ResponseWriter, rosettaRequestID string, getAdditionalHeaders func(string) (http.Header, bool), ) *ResponseWriter
func (*ResponseWriter) AddExtractedHeaders ¶
func (hfrw *ResponseWriter) AddExtractedHeaders()
func (*ResponseWriter) Header ¶
func (hfrw *ResponseWriter) Header() http.Header
Header passes through to the underlying ResponseWriter instance
func (*ResponseWriter) Write ¶
func (hfrw *ResponseWriter) Write(b []byte) (int, error)
Write passes through to the underlying ResponseWriter instance
func (*ResponseWriter) WriteHeader ¶
func (hfrw *ResponseWriter) WriteHeader(statusCode int)
WriteHeader will add any final extracted headers, and then pass through to the underlying ResponseWriter instance