Documentation ¶
Index ¶
- Constants
- func CopyTrace(ctx context.Context, req *http.Request) error
- func DecodeObject(source structure.Source, reader io.Reader, object interface{}) error
- func DecodeRequestBody(req *http.Request, object interface{}) error
- func DecodeRequestQuery(req *http.Request, objectParsables ...structure.ObjectParsable) error
- func DecodeResponseBody(res *http.Response, object interface{}) error
- func DecodeValues(values url.Values, objectParsables ...structure.ObjectParsable) error
- func ErrorJSONMalformed() error
- func ErrorParameterMissing(parameter string) error
- func ErrorResourceNotFound() error
- func ErrorResourceNotFoundWithID(id string) error
- func ErrorUnauthenticated() error
- func ErrorUnauthorized() error
- func ErrorUnexpectedResponse(res *http.Response, req *http.Request) error
- func NewContextWithDetails(ctx context.Context, details Details) context.Context
- func NewContextWithTraceRequest(ctx context.Context, traceRequest string) context.Context
- func NewContextWithTraceSession(ctx context.Context, traceSession string) context.Context
- func NormalizeObjects(source structure.Source, objects ...interface{}) error
- func ParseArrayParseableStreamObject(source structure.Source, reader io.Reader, ...) error
- func ParseObjectParseableStreamObject(source structure.Source, reader io.Reader, ...) error
- func ParseSimpleStreamObject(reader io.Reader, object interface{}) error
- func ParseStreamObject(source structure.Source, reader io.Reader, object interface{}) error
- func ParseValuesObjects(values url.Values, objectParsables ...structure.ObjectParsable) error
- func StatusCodeForError(err error) int
- func TraceRequestFromContext(ctx context.Context) string
- func TraceSessionFromContext(ctx context.Context) string
- func ValidateObjects(source structure.Source, objects ...interface{}) error
- type Details
- type Method
- type Responder
- func (r *Responder) Data(statusCode int, data interface{})
- func (r *Responder) Empty(statusCode int)
- func (r *Responder) Error(statusCode int, err error)
- func (r *Responder) HTML(statusCode int, html string)
- func (r *Responder) Redirect(statusCode int, url string)
- func (r *Responder) SetCookie(cookie *http.Cookie)
- type Sanitizable
- type Values
- func (v *Values) Array(reference string) *[]interface{}
- func (v *Values) Bool(reference string) *bool
- func (v *Values) Exists() bool
- func (v *Values) Float64(reference string) *float64
- func (v *Values) Int(reference string) *int
- func (v *Values) Interface(reference string) *interface{}
- func (v *Values) NotParsed() error
- func (v *Values) Object(reference string) *map[string]interface{}
- func (v *Values) Parse(objectParsable structure.ObjectParsable) error
- func (v *Values) ReferenceExists(reference string) bool
- func (v *Values) References() []string
- func (v *Values) String(reference string) *string
- func (v *Values) StringArray(reference string) *[]string
- func (v *Values) Time(reference string, layout string) *time.Time
- func (v *Values) WithMeta(meta interface{}) structure.ObjectParser
- func (v *Values) WithReferenceArrayParser(reference string) structure.ArrayParser
- func (v *Values) WithReferenceObjectParser(reference string) structure.ObjectParser
- func (v *Values) WithSource(source structure.Source) *Values
Constants ¶
View Source
const ( ErrorCodeUnexpectedResponse = "unexpected-response" ErrorCodeUnauthenticated = "unauthenticated" ErrorCodeResourceNotFound = "resource-not-found" ErrorCodeParameterMissing = "parameter-missing" ErrorCodeJSONMalformed = "json-malformed" )
View Source
const ( HTTPHeaderTraceRequest = "X-Tidepool-Trace-Request" HTTPHeaderTraceSession = "X-Tidepool-Trace-Session" )
View Source
const ( MethodServiceSecret = "service secret" MethodAccessToken = "access token" MethodSessionToken = "session token" MethodRestrictedToken = "restricted token" )
Variables ¶
This section is empty.
Functions ¶
func DecodeObject ¶
func DecodeRequestBody ¶
func DecodeRequestQuery ¶
func DecodeRequestQuery(req *http.Request, objectParsables ...structure.ObjectParsable) error
func DecodeResponseBody ¶
func DecodeValues ¶
func DecodeValues(values url.Values, objectParsables ...structure.ObjectParsable) error
func ErrorJSONMalformed ¶
func ErrorJSONMalformed() error
func ErrorParameterMissing ¶
func ErrorResourceNotFound ¶
func ErrorResourceNotFound() error
func ErrorUnauthenticated ¶
func ErrorUnauthenticated() error
func ErrorUnauthorized ¶
func ErrorUnauthorized() error
func ErrorUnexpectedResponse ¶
func NewContextWithDetails ¶
func NormalizeObjects ¶
func ParseSimpleStreamObject ¶
func ParseStreamObject ¶
func ParseValuesObjects ¶
func ParseValuesObjects(values url.Values, objectParsables ...structure.ObjectParsable) error
func StatusCodeForError ¶
func TraceRequestFromContext ¶
func TraceSessionFromContext ¶
func ValidateObjects ¶
Types ¶
type Details ¶
type Details interface { Method() Method IsService() bool IsUser() bool UserID() string HasToken() bool Token() string }
func DetailsFromContext ¶
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
func MustNewResponder ¶
func MustNewResponder(res rest.ResponseWriter, req *rest.Request) *Responder
func NewResponder ¶
type Sanitizable ¶
type Values ¶
func (*Values) ReferenceExists ¶
func (*Values) References ¶
func (*Values) StringArray ¶
func (*Values) WithMeta ¶
func (v *Values) WithMeta(meta interface{}) structure.ObjectParser
func (*Values) WithReferenceArrayParser ¶
func (v *Values) WithReferenceArrayParser(reference string) structure.ArrayParser
func (*Values) WithReferenceObjectParser ¶
func (v *Values) WithReferenceObjectParser(reference string) structure.ObjectParser
Click to show internal directories.
Click to hide internal directories.