Documentation
¶
Index ¶
- Constants
- Variables
- func BindFromRequest(request *http.Request, resourceType reflect.Type, subject auth.Subject, ...) (resource.Resource, gomerr.Gomerr)
- func BindToResponse(result reflect.Value, header http.Header, scope string, acceptLanguage string) (output []byte, ge gomerr.Gomerr)
- func SetBindFromRequestConfiguration(requestConfiguration BindFromRequestConfiguration) *structs.Tool
- func SetBindToResponseConfiguration(responseConfiguration BindToResponseConfiguration) *structs.Tool
- type BindDirectiveConfiguration
- type BindFromRequestConfiguration
- type BindToResponseConfiguration
- type EmptyDirectiveHandlingType
- type EmptyValueHandlingType
- type Marshal
- type Marshaler
- type Method
- type Op
- type StatusCoder
- type Unmarshal
Constants ¶
const ( DefaultContentType = "application/json" DefaultPathBindingPrefix = "path." DefaultHeaderBindingPrefix = "header." DefaultQueryParamBindingPrefix = "query." DefaultPayloadBindingPrefix = "" DefaultSkipFieldDirective = "-" DefaultBindToFieldNameDirective = "+" DefaultBodyBindingDirective = "body" DefaultEmptyDirectiveHandling = SkipField DefaultOmitEmptyDirective = "omitempty" DefaultIncludeEmptyDirective = "includeempty" DefaultEmptyValueHandlingDefault = OmitEmpty ContentTypeHeader = "Content-Type" AcceptsHeader = "Accepts" AcceptLanguageKey = "$_accept_language" )
const ( PutCollection = Put + collection PostCollection = Post + collection GetCollection = Get + collection PatchCollection = Patch + collection DeleteCollection = Delete_ + collection HeadCollection = Head + collection OptionsCollection = Options + collection PutInstance = Put + instance PostInstance = Post + instance GetInstance = Get + instance PatchInstance = Patch + instance DeleteInstance = Delete_ + instance HeadInstance = Head + instance OptionsInstance = Options + instance )
const InvalidHttpOp = 0b00000000
const StatusLimitExceeded = 402
Variables ¶
var (
DefaultBindFromRequestTool *structs.Tool
)
var (
DefaultBindToResponseTool *structs.Tool
)
Functions ¶
func BindFromRequest ¶
func BindToResponse ¶
func BindToResponse(result reflect.Value, header http.Header, scope string, acceptLanguage string) (output []byte, ge gomerr.Gomerr)
BindToResponse TODO: add support for data format type
func SetBindFromRequestConfiguration ¶
func SetBindFromRequestConfiguration(requestConfiguration BindFromRequestConfiguration) *structs.Tool
func SetBindToResponseConfiguration ¶
func SetBindToResponseConfiguration(responseConfiguration BindToResponseConfiguration) *structs.Tool
Types ¶
type BindDirectiveConfiguration ¶
type BindDirectiveConfiguration struct { // Default prefixes for qualified directives PathBindingPrefix string HeaderBindingPrefix string QueryParamBindingPrefix string PayloadBindingPrefix string // Default values for unqualified directives SkipField string IncludeField string BindBody string // Defines how a field's binding be handled if no directive is specified. Default is to skip. EmptyDirectiveHandling EmptyDirectiveHandlingType OmitEmptyDirective string IncludeEmptyDirective string // Defines how an empty value is marshaled unless overridden by OmitEmptyDirective or IncludeEmptyDirective. Default // is to omit. EmptyValueHandlingDefault EmptyValueHandlingType }
func NewBindDirectiveConfiguration ¶
func NewBindDirectiveConfiguration() BindDirectiveConfiguration
type BindFromRequestConfiguration ¶
type BindFromRequestConfiguration struct { BindConfiguration bind2.Configuration BindDirectiveConfiguration // contains filtered or unexported fields }
BindFromRequestConfiguration TODO: add config option mechanism...
func NewBindFromRequestConfiguration ¶
func NewBindFromRequestConfiguration() BindFromRequestConfiguration
type BindToResponseConfiguration ¶
type BindToResponseConfiguration struct { BindConfiguration bind.Configuration BindDirectiveConfiguration // contains filtered or unexported fields }
BindToResponseConfiguration TODO: add config option mechanism...
func NewBindToResponseConfiguration ¶
func NewBindToResponseConfiguration() BindToResponseConfiguration
type EmptyDirectiveHandlingType ¶
type EmptyDirectiveHandlingType int
const ( SkipField EmptyDirectiveHandlingType = iota BindToFieldName )
type EmptyValueHandlingType ¶
type EmptyValueHandlingType int
const ( OmitEmpty EmptyValueHandlingType = iota IncludeEmpty )
type Marshal ¶
Marshal provides a function to convert the toMarshal to bytes suitable for returning in a response body.
type Method ¶
type Method = Op
const ( Put Method // 0b00000001 Post // 0b00000010 Get // 0b00000011 Patch // 0b00000100 Delete_ // 0b00000101 Head // 0b00000110 Options // 0b00000111 )
type Op ¶
type Op byte
Op has 8 bits where the bottom five bits correspond to the action type, the sixth and seventh bit specifies what resource type the action is against (instance or a collection; a singleton counts as an instance) and the highest bit indicates if the op is built-in or customer-defined. The seventh bit is reserved. Use NewOp rather than try to construct manually to allow for the introduction of new, built-in Method values.
func (Op) ResourceType ¶
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}