request

package
v1.20.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2017 License: BSD-3-Clause Imports: 16 Imported by: 23

Documentation

Index

Constants

View Source
const (
	ErrorCodeUnexpectedResponse = "unexpected-response"
	ErrorCodeUnauthenticated    = "unauthenticated"
	ErrorCodeUnauthorized       = "unauthorized"
	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 CopyTrace

func CopyTrace(ctx context.Context, req *http.Request) error

func DecodeObject

func DecodeObject(source structure.Source, reader io.Reader, object interface{}) error

func DecodeRequestBody

func DecodeRequestBody(req *http.Request, object interface{}) error

func DecodeRequestQuery

func DecodeRequestQuery(req *http.Request, objectParsables ...structure.ObjectParsable) error

func DecodeResponseBody

func DecodeResponseBody(res *http.Response, object interface{}) error

func DecodeValues

func DecodeValues(values url.Values, objectParsables ...structure.ObjectParsable) error

func ErrorJSONMalformed

func ErrorJSONMalformed() error

func ErrorParameterMissing

func ErrorParameterMissing(parameter string) error

func ErrorResourceNotFound

func ErrorResourceNotFound() error

func ErrorResourceNotFoundWithID

func ErrorResourceNotFoundWithID(id string) error

func ErrorUnauthenticated

func ErrorUnauthenticated() error

func ErrorUnauthorized

func ErrorUnauthorized() error

func ErrorUnexpectedResponse

func ErrorUnexpectedResponse(res *http.Response, req *http.Request) error

func NewContextWithDetails

func NewContextWithDetails(ctx context.Context, details Details) context.Context

func NewContextWithTraceRequest

func NewContextWithTraceRequest(ctx context.Context, traceRequest string) context.Context

func NewContextWithTraceSession

func NewContextWithTraceSession(ctx context.Context, traceSession string) context.Context

func NormalizeObjects

func NormalizeObjects(source structure.Source, objects ...interface{}) error

func ParseArrayParseableStreamObject

func ParseArrayParseableStreamObject(source structure.Source, reader io.Reader, arrayParsable structure.ArrayParsable) error

func ParseObjectParseableStreamObject

func ParseObjectParseableStreamObject(source structure.Source, reader io.Reader, objectParsable structure.ObjectParsable) error

func ParseSimpleStreamObject

func ParseSimpleStreamObject(reader io.Reader, object interface{}) error

func ParseStreamObject

func ParseStreamObject(source structure.Source, reader io.Reader, object interface{}) error

func ParseValuesObjects

func ParseValuesObjects(values url.Values, objectParsables ...structure.ObjectParsable) error

func StatusCodeForError

func StatusCodeForError(err error) int

func TraceRequestFromContext

func TraceRequestFromContext(ctx context.Context) string

func TraceSessionFromContext

func TraceSessionFromContext(ctx context.Context) string

func ValidateObjects

func ValidateObjects(source structure.Source, objects ...interface{}) error

Types

type Details

type Details interface {
	Method() Method

	IsService() bool
	IsUser() bool
	UserID() string

	HasToken() bool
	Token() string
}

func DetailsFromContext

func DetailsFromContext(ctx context.Context) Details

func NewDetails

func NewDetails(method Method, userID string, token string) Details

type Method

type Method string

type Responder

type Responder struct {
	// contains filtered or unexported fields
}

func MustNewResponder

func MustNewResponder(res rest.ResponseWriter, req *rest.Request) *Responder

func NewResponder

func NewResponder(res rest.ResponseWriter, req *rest.Request) (*Responder, error)

func (*Responder) Data

func (r *Responder) Data(statusCode int, data interface{})

func (*Responder) Empty

func (r *Responder) Empty(statusCode int)

func (*Responder) Error

func (r *Responder) Error(statusCode int, err error)

func (*Responder) HTML

func (r *Responder) HTML(statusCode int, html string)

func (*Responder) Redirect

func (r *Responder) Redirect(statusCode int, url string)

func (*Responder) SetCookie

func (r *Responder) SetCookie(cookie *http.Cookie)

type Sanitizable

type Sanitizable interface {
	Sanitize(details Details) error
}

type Values

type Values struct {
	structure.Base
	// contains filtered or unexported fields
}

func NewValues

func NewValues(values *url.Values) *Values

func NewValuesParser

func NewValuesParser(base structure.Base, values *url.Values) *Values

func (*Values) Array

func (v *Values) Array(reference string) *[]interface{}

func (*Values) Bool

func (v *Values) Bool(reference string) *bool

func (*Values) Exists

func (v *Values) Exists() bool

func (*Values) Float64

func (v *Values) Float64(reference string) *float64

func (*Values) Int

func (v *Values) Int(reference string) *int

func (*Values) Interface

func (v *Values) Interface(reference string) *interface{}

func (*Values) NotParsed

func (v *Values) NotParsed() error

func (*Values) Object

func (v *Values) Object(reference string) *map[string]interface{}

func (*Values) Parse

func (v *Values) Parse(objectParsable structure.ObjectParsable) error

func (*Values) ReferenceExists

func (v *Values) ReferenceExists(reference string) bool

func (*Values) References

func (v *Values) References() []string

func (*Values) String

func (v *Values) String(reference string) *string

func (*Values) StringArray

func (v *Values) StringArray(reference string) *[]string

func (*Values) Time

func (v *Values) Time(reference string, layout string) *time.Time

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

func (*Values) WithSource

func (v *Values) WithSource(source structure.Source) *Values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL