mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-29 23:22:45 +00:00
5e871e81a8
* otel to 1.24 * prometheus exporter to 0.46 * bunotel to 1.1.17 Also: * Use schemaless URL for metrics * Add software version to tracing schema
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package runtime
|
|
|
|
import (
|
|
"google.golang.org/genproto/googleapis/api/httpbody"
|
|
)
|
|
|
|
// HTTPBodyMarshaler is a Marshaler which supports marshaling of a
|
|
// google.api.HttpBody message as the full response body if it is
|
|
// the actual message used as the response. If not, then this will
|
|
// simply fallback to the Marshaler specified as its default Marshaler.
|
|
type HTTPBodyMarshaler struct {
|
|
Marshaler
|
|
}
|
|
|
|
// ContentType returns its specified content type in case v is a
|
|
// google.api.HttpBody message, otherwise it will fall back to the default Marshalers
|
|
// content type.
|
|
func (h *HTTPBodyMarshaler) ContentType(v interface{}) string {
|
|
if httpBody, ok := v.(*httpbody.HttpBody); ok {
|
|
return httpBody.GetContentType()
|
|
}
|
|
return h.Marshaler.ContentType(v)
|
|
}
|
|
|
|
// Marshal marshals "v" by returning the body bytes if v is a
|
|
// google.api.HttpBody message, otherwise it falls back to the default Marshaler.
|
|
func (h *HTTPBodyMarshaler) Marshal(v interface{}) ([]byte, error) {
|
|
if httpBody, ok := v.(*httpbody.HttpBody); ok {
|
|
return httpBody.GetData(), nil
|
|
}
|
|
return h.Marshaler.Marshal(v)
|
|
}
|