util

package
v0.0.0-...-28756f2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureTrailingSlash

func EnsureTrailingSlash(URL string) string

EnsureTrailingSlash appends a slash at the end of the given string unless there already is one. This is used to create the kind of normalized URLs that Django expects. (to avoid Django's redirection when an URL does not ends with a slash.)

func IsBadRequestError

func IsBadRequestError(err error) bool

IsBadRequestError returns true if err is a NoMatchError.

func IsCannotCompleteError

func IsCannotCompleteError(err error) bool

IsCannotCompleteError returns true if err is a NoMatchError.

func IsDeserializationError

func IsDeserializationError(err error) bool

IsDeserializationError returns true if err is a DeserializationError.

func IsNoMatchError

func IsNoMatchError(err error) bool

IsNoMatchError returns true if err is a NoMatchError.

func IsPermissionError

func IsPermissionError(err error) bool

IsPermissionError returns true if err is a NoMatchError.

func IsUnexpectedError

func IsUnexpectedError(err error) bool

IsUnexpectedError returns true if err is an UnexpectedError.

func IsUnsupportedVersionError

func IsUnsupportedVersionError(err error) bool

IsUnsupportedVersionError returns true if err is an UnsupportedVersionError.

func JoinURLs

func JoinURLs(baseURL, path string) string

JoinURLs joins a base URL and a subpath together. Regardless of whether baseURL ends in a trailing slash (or even multiple trailing slashes), or whether there are any leading slashes at the begining of Path, the two will always be joined together by a single slash.

func NewBadRequestError

func NewBadRequestError(message string) error

NewBadRequestError constructs a new BadRequestError and sets the location.

func NewCannotCompleteError

func NewCannotCompleteError(message string) error

NewCannotCompleteError constructs a new CannotCompleteError and sets the location.

func NewDeserializationError

func NewDeserializationError(format string, args ...interface{}) error

NewDeserializationError constructs a new DeserializationError and sets the location.

func NewNoMatchError

func NewNoMatchError(message string) error

NewNoMatchError constructs a new NoMatchError and sets the location.

func NewPermissionError

func NewPermissionError(message string) error

NewPermissionError constructs a new PermissionError and sets the location.

func NewUnexpectedError

func NewUnexpectedError(err error) error

NewUnexpectedError constructs a new UnexpectedError and sets the location.

func NewUnsupportedVersionError

func NewUnsupportedVersionError(format string, args ...interface{}) error

NewUnsupportedVersionError constructs a new UnsupportedVersionError and sets the location.

func ParseJSON

func ParseJSON(t *testing.T, source string) interface{}

ParseJSON parses a string source a map to be used in testing

func UpdateJSONMap

func UpdateJSONMap(t *testing.T, source string, changes map[string]interface{}) string

UpdateJSONMap updates a json with changes

func WrapWithDeserializationError

func WrapWithDeserializationError(err error, format string, args ...interface{}) error

WrapWithDeserializationError constructs a new DeserializationError with the specified message, and sets the location and returns a new error with the full error stack set including the error passed in.

func WrapWithUnsupportedVersionError

func WrapWithUnsupportedVersionError(err error) error

WrapWithUnsupportedVersionError constructs a new UnsupportedVersionError wrapping the passed error.

Types

type BadRequestError

type BadRequestError struct {
	errors.Err
}

BadRequestError is returned when the requested action cannot be performed due to bad or incorrect parameters passed to the server.

type CannotCompleteError

type CannotCompleteError struct {
	errors.Err
}

CannotCompleteError is returned when the requested action is unable to complete for some server side reason.

type DeserializationError

type DeserializationError struct {
	errors.Err
}

DeserializationError types are returned when the returned JSON data from the ControllerInterface doesn't match the code's expectations.

type NoMatchError

type NoMatchError struct {
	errors.Err
}

NoMatchError is returned when the requested action cannot be performed due to being unable to service due to no entities available that match the request.

type PermissionError

type PermissionError struct {
	errors.Err
}

PermissionError is returned when the user does not have permission to do the requested action.

type URLParams

type URLParams struct {
	Values url.Values
}

URLParams wraps url.Values to easily add Values, but skipping empty ones.

func NewURLParams

func NewURLParams() *URLParams

NewURLParams allocates a new URLParams type.

func (*URLParams) MaybeAdd

func (p *URLParams) MaybeAdd(name, value string)

MaybeAdd adds the (Name, value) pair iff value is not empty.

func (*URLParams) MaybeAddBool

func (p *URLParams) MaybeAddBool(name string, value bool)

MaybeAddBool adds the (Name, value) pair iff value is true.

func (*URLParams) MaybeAddInt

func (p *URLParams) MaybeAddInt(name string, value int)

MaybeAddInt adds the (Name, value) pair iff value is not zero.

func (*URLParams) MaybeAddMany

func (p *URLParams) MaybeAddMany(name string, values []string)

MaybeAddMany adds the (Name, value) for each value in Values iff value is not empty.

type UnexpectedError

type UnexpectedError struct {
	errors.Err
}

UnexpectedError is an error for a condition that hasn't been determined.

type UnsupportedVersionError

type UnsupportedVersionError struct {
	errors.Err
}

UnsupportedVersionError refers to calls made to an unsupported api version.

Jump to

Keyboard shortcuts

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