Documentation
¶
Index ¶
- Constants
- func FilterBodyOn204(inner http.Handler) (http.Handler, error)
- func GetExpiresHeader(ctx context.Context) (string, bool)
- func GetStatusCode(ctx context.Context) (int, bool)
- func MarshalAsJSON(obj proto.Message) ([]byte, error)
- func RewriteRequest(r *http.Request, newURL *url.URL) *http.Request
- func SetExpiresHeader(ctx context.Context, expiresAt time.Time)
- func SetStatusCode(ctx context.Context, code int)
- type ErrorResponse
- type ErrorResponseDetails
- type Options
- type ServeMux
Constants ¶
View Source
const MetadataKeyExpires = "x-expires"
View Source
const MetadataKeyStatusCode = "x-http-code"
Variables ¶
This section is empty.
Functions ¶
func RewriteRequest ¶
RewriteRequest returns a new http.Request for the specified URL, also stashing the original request for addMetadata.
func SetStatusCode ¶
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Code int `json:"code,omitempty"` Message string `json:"message,omitempty"` Status string `json:"status,omitempty"` Errors []ErrorResponseDetails `json:"errors,omitempty"` }
type ErrorResponseDetails ¶
type Options ¶
type Options struct { // If EmitUnpopulated is true, we will send empty proto fields (false / "" / 0 etc) // Some older APIs do this (e.g. cloudbilling) // While it likely doesn't matter, it makes golden testing easier to match. EmitUnpopulated bool }
type ServeMux ¶
type ServeMux struct { ServeMux *runtime.ServeMux // RewriteError allows us to customize the error we return. // Error can be changed in-place. RewriteError func(ctx context.Context, error *ErrorResponse) // RewriteHeaders allows us to customize the headers we return. // Response is changed in-place. RewriteHeaders func(ctx context.Context, response http.ResponseWriter, payload proto.Message) }
Click to show internal directories.
Click to hide internal directories.