types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAuthorized defines a not authorized error
	ErrNotAuthorized = NewError().Status(http.StatusUnauthorized).Format("not authorized")

	// ErrInvalidParameter defines an invalid parameter error
	ErrInvalidParameter = NewError().Status(http.StatusBadRequest).Format("invalid parameter")

	// ErrNotImplemented defines a not implemented error
	ErrNotImplemented = NewError().Status(http.StatusNotImplemented).FormatFunc("method '%s' not implemented")

	// ErrResourceConflict is returned when an object conflicts with one that already exists
	ErrResourceConflict = NewError().Status(http.StatusConflict).FormatFunc("'%s' conflicts with one that already exists")

	// ErrNotFound is is returned when an object was not found
	ErrNotFound = NewError().Status(http.StatusNotFound).FormatFunc("'%s' not found")

	// ErrServerError is reserved for server errors
	ErrServerError = NewError().Status(http.StatusInternalServerError).FormatFunc("server error: %s")
)
View Source
var (
	// NoContentResponse is a no content HTTP success response
	NoContentResponse = NewResponse().SetStatus(http.StatusNoContent)

	// SeeOtherResponse returns a redirect response
	SeeOtherResponse = func(loc string) *Response {
		return NewResponse().SetStatus(http.StatusSeeOther).SetHeader("Location", loc)
	}
)

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    *string           `json:"code,omitempty"`
	Message *string           `json:"message,omitempty"`
	Detail  map[string]string `json:"detail,omitempty"`
	// contains filtered or unexported fields
}

Error is the common error struct compatible with swagger response types

func NewError

func NewError(err ...error) *Error

NewError returns a new models.Error from a go error

func (*Error) BodyLength

func (e *Error) BodyLength() int

BodyLength returns the http body length in bytes

func (*Error) Err

func (e *Error) Err() error

Err returns the underlining error

func (*Error) Error

func (e *Error) Error() string

Err returns the go error

func (*Error) ErrorCode

func (e *Error) ErrorCode(code string) *Error

ErrorCode sets the error code

func (*Error) Format

func (e *Error) Format(msg string, args ...interface{}) *Error

Format formats the error message

func (*Error) FormatFunc

func (e *Error) FormatFunc(msg string) func(args ...interface{}) *Error

FormatFunc func formats a error message functor

func (*Error) Header

func (e *Error) Header() http.Header

Header returns the http header

func (*Error) Reason

func (e *Error) Reason(args ...interface{}) *Error

Reason sets the detail for the error

func (*Error) Scan

func (e *Error) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (*Error) Status

func (e *Error) Status(status int) *Error

Status sets the http status

func (*Error) StatusCode

func (e *Error) StatusCode() int

StatusCode returns the http statuscode

func (*Error) String

func (e *Error) String() string

func (*Error) Validate

func (*Error) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

func (Error) Value

func (e Error) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

func (*Error) WriteResponse

func (e *Error) WriteResponse(rw http.ResponseWriter, pr runtime.Producer)

WriteResponse implements the middleware.Responder interface

type JSONMap

type JSONMap map[string]interface{}

JSONMap is a helper for the postgres jsonb datatype

func (JSONMap) Bool

func (p JSONMap) Bool(key string, def ...bool) bool

Bool parses and returns the boolean value of the parameter

func (JSONMap) Copy

func (p JSONMap) Copy() JSONMap

Copy does a shallow copy

func (JSONMap) Delete

func (p JSONMap) Delete(key string)

Delete removes a key

func (JSONMap) Float64

func (p JSONMap) Float64(key string, def ...float64) float64

Float64 returns the float value or 0 if not set

func (JSONMap) Get

func (p JSONMap) Get(key string, def ...interface{}) (interface{}, bool)

Get returns the value and if the key is set

func (JSONMap) Int64

func (p JSONMap) Int64(key string, def ...int64) int64

Int64 returns the int value or 0 if not set

func (JSONMap) IsSet

func (p JSONMap) IsSet(key string) bool

IsSet returns true if the parameter is set

func (JSONMap) IsSetV

func (p JSONMap) IsSetV(key string) (Value, bool)

IsSetV returns true if the parameter is set and the value

func (*JSONMap) Scan

func (p *JSONMap) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (JSONMap) Set

func (p JSONMap) Set(key string, value interface{})

Set sets a value in the map

func (JSONMap) String

func (p JSONMap) String(key string, def ...string) string

String returns a string value for the param, or the optional default

func (JSONMap) StringPtr

func (p JSONMap) StringPtr(key string, def ...string) *string

StringPtr returns a string ptr or nil

func (JSONMap) StringSlice

func (p JSONMap) StringSlice(key string) []string

StringSlice returns a string value for the param, or the optional default

func (JSONMap) Sub

func (p JSONMap) Sub(key string) JSONMap

Sub returns a sub JSONMap for the key

func (*JSONMap) Validate

func (*JSONMap) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

func (JSONMap) Value

func (p JSONMap) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

func (JSONMap) Without

func (p JSONMap) Without(keys ...string) JSONMap

Without removes the keys, returns a shallow copy

type Link struct {

	// expires at
	ExpiresAt int64 `json:"expires_at,omitempty"`

	// the target url/uri
	// Format: uri
	Href strfmt.URI `json:"href,omitempty"`

	// optional link name
	Name *string `json:"name,omitempty"`
}

Link an href link object swagger:model Link

func (*Link) MarshalBinary

func (m *Link) MarshalBinary() ([]byte, error)

MarshalBinary interface implementation

func (*Link) UnmarshalBinary

func (m *Link) UnmarshalBinary(b []byte) error

UnmarshalBinary interface implementation

func (*Link) Validate

func (m *Link) Validate(formats strfmt.Registry) error

Validate validates this link

type Model

type Model struct {
	// Universally unique identifier
	// Read Only: true
	ID strfmt.UUID4 `json:"uuid,omitempty"`

	// Date and time of object creation
	// Read Only: true
	CreatedAt strfmt.DateTime `json:"_created_at,omitempty" sql:"column:_created_at"`

	// User uuid that created the object
	// Read Only: true
	CreatedBy string `json:"_created_by,omitempty" sql:"column:_created_by"`

	// Last date of object modification
	// Read Only: true
	UpdatedAt strfmt.DateTime `json:"_updated_at,omitempty" sql:"column:_updated_at"`

	// User that updated the object
	// Read Only: true
	UpdatedBy string `json:"_updated_by,omitempty" sql:"column:_updated_by"`

	// meta
	Meta *hstore.Hstore `json:"meta,omitempty"`

	// tags
	Tags StringArray `json:"tags,omitempty"`
}

Model is the base datebase model type used by Model Rocket

func (*Model) MarshalBinary

func (m *Model) MarshalBinary() ([]byte, error)

MarshalBinary interface implementation

func (*Model) UnmarshalBinary

func (m *Model) UnmarshalBinary(b []byte) error

UnmarshalBinary interface implementation

func (*Model) Validate

func (m *Model) Validate(formats strfmt.Registry) error

Validate validates this base model

type Params

type Params = JSONMap

Params is a simple type alias for a JSONMap

func ParseStringParams

func ParseStringParams(s string) Params

ParseStringParams parses a parameter string and returns a params object Example string: foo=bar aparam="value"

type Response

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

Response defines a simple middleware.Responder struct

func NewResponse

func NewResponse(options ...*ResponseOptions) *Response

NewResponse returns a new response object

func (*Response) Body

func (r *Response) Body() []byte

Body returns the body

func (*Response) Copy

func (r *Response) Copy() *Response

Copy copies a response

func (*Response) Header

func (r *Response) Header() http.Header

Header implements the http.ResponseWriter

func (*Response) Length

func (r *Response) Length() int

Length returns the response length

func (*Response) SetAcceleration

func (r *Response) SetAcceleration(acc bool) *Response

SetAcceleration enables json acceleration

func (*Response) SetHeader

func (r *Response) SetHeader(name, value string) *Response

SetHeader sets additional response headers

func (*Response) SetHeaderMap

func (r *Response) SetHeaderMap(vals map[string]string) *Response

SetHeaderMap sets additional response headers

func (*Response) SetHeaders

func (r *Response) SetHeaders(h http.Header) *Response

SetHeaders sets all of the headers

func (*Response) SetOptions

func (r *Response) SetOptions(options ...*ResponseOptions) *Response

SetOptions sets the options for a response

func (*Response) SetPayload

func (r *Response) SetPayload(payload interface{}) *Response

SetPayload sets the payload

func (*Response) SetStatus

func (r *Response) SetStatus(s int) *Response

SetStatus sets the response http status

func (*Response) StatusCode

func (r *Response) StatusCode() int

StatusCode returns the response http status code

func (*Response) Write

func (r *Response) Write(body []byte) (int, error)

Write implements the http.ResponseWriter.Write() method

func (*Response) WriteHeader

func (r *Response) WriteHeader(statusCode int)

WriteHeader implements the http.ResponseWriter.WriteHeader() method

func (*Response) WriteResponse

func (r *Response) WriteResponse(rw http.ResponseWriter, pr runtime.Producer)

WriteResponse implements the middleware.Responder.WriteResponse() method

type ResponseOptions

type ResponseOptions struct {
	Request      *http.Request
	Encoding     string
	ContentType  string
	Binary       bool
	Acceleration bool
}

ResponseOptions defines responder options

type StringArray

type StringArray pq.StringArray

StringArray is a proper string array type

func (*StringArray) Scan

func (a *StringArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (*StringArray) Validate

func (*StringArray) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

func (StringArray) Value

func (a StringArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type StringMap

type StringMap hstore.Hstore

StringMap is a proper string array type

func (*StringMap) Validate

func (*StringMap) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

type UUIDArray

type UUIDArray []strfmt.UUID

UUIDArray is a proper string array type

func (*UUIDArray) Scan

func (a *UUIDArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface

func (UUIDArray) Strings

func (a UUIDArray) Strings() []string

Strings returns a string slice from the uuid array

func (*UUIDArray) Validate

func (*UUIDArray) Validate(formats strfmt.Registry) error

Validate handles the strfmt validation for the StringArray object

func (UUIDArray) Value

func (a UUIDArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Value

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

Value defines a value wrapper

func NewValue

func NewValue(v interface{}) Value

NewValue returns a new value with cast helpers

func (Value) Bool

func (v Value) Bool() bool

Bool casts the value to a bool

func (Value) Float64

func (v Value) Float64() float64

Float64 casts the value to a float64

func (Value) Int64

func (v Value) Int64() int64

Int64 casts the value to an int64

func (Value) String

func (v Value) String() string

String casts the value to a string

func (Value) StringPtr

func (v Value) StringPtr() *string

StringPtr casts the value to a string pointer

func (Value) StringSlice

func (v Value) StringSlice() []string

StringSlice casts the value to a string slice

Directories

Path Synopsis
geo
encoding/postgis
Package wkb implements Well Known Binary encoding and decoding.
Package wkb implements Well Known Binary encoding and decoding.

Jump to

Keyboard shortcuts

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