HTTP

package
v0.0.0-...-3e52749 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureNumber

func EnsureNumber(field string, value string) (int64, error)

EnsureNumber is a helper function that takes a query value as a string, and converts it. If this fails, it returns the appropriate Error.

func EnsurePositiveNumber

func EnsurePositiveNumber(field string, value string) (int64, error)

EnsurePositiveNumber is a helper function that takes a query value as a string, converts it, and range checks it. If any of those operations fail it returns the appropriate Error.

func PostError

func PostError(ctx context.Context, w http.ResponseWriter, err error)

PostError sets the appropriate http error, and logs it to the tracing system.

func PostErrorIf

func PostErrorIf(ctx context.Context, w http.ResponseWriter, err error)

PostErrorIf sets and traces the http error, if there is one.

Types

type Error

type Error struct {
	// HTTP status code
	SC int

	// Underlying Go error
	Base error
}

Error is a custom common HTTP error type that includes the status code to use in a response.

func NewErrBadMatchType

func NewErrBadMatchType(match string) *Error

NewErrBadMatchType indicates that the If-Match value was syntactically incorrect, and could not be processed

func NewErrBladeNotFound

func NewErrBladeNotFound(rackId string, bladeId int64) *Error

NewErrBladeNotFound indicates that the rack was found but no blade was found

func NewErrInvalidNumber

func NewErrInvalidNumber(field string, value string) *Error

NewErrInvalidNumber indicates that the specified value could not be processed as a number.

func NewErrInvalidPositiveNumber

func NewErrInvalidPositiveNumber(field string, value string) *Error

NewErrInvalidPositiveNumber indicates that the specified value could not be processed as a positive number.

func NewErrInvalidRateRequest

func NewErrInvalidRateRequest() *Error

NewErrInvalidRateRequest indicates that the automatic ticks-per-second rate was present, but the selected policy mode was not 'automatic'.

func NewErrInvalidStepperMode

func NewErrInvalidStepperMode(mode string) *Error

NewErrInvalidStepperMode indicates that an unrecognized simulated policy mode was requested.

func NewErrInvalidStepperRate

func NewErrInvalidStepperRate(rate string) *Error

NewErrInvalidStepperRate indicates that the supplied ticks-per-second rate was not recognized as a valid number.

func NewErrNoLoginActive

func NewErrNoLoginActive(name string) *Error

NewErrNoLoginActive indicates that the specified user is not logged into this session

func NewErrNoSessionActive

func NewErrNoSessionActive() *Error

NewErrNoSessionActive indicates that the request was made without first establishing a logged-in session

func NewErrPduNotFound

func NewErrPduNotFound(rackId string, pduID int64) *Error

NewErrPduNotFound indicates that the rack was found but no pdu was found

func NewErrRackNotFound

func NewErrRackNotFound(name string) *Error

NewErrRackNotFound indicates the specified rack do not exist and the http request (http.statusNotFound) determines to be the request was made against a non-existing rack.

func NewErrRegionNotFound

func NewErrRegionNotFound(name string) *Error

NewErrRegionNotFound indicates the specified region does not exist and the http request (http.statusNotFound) determines to be the request was made against a non-existing region.

func NewErrSessionNotFound

func NewErrSessionNotFound(id int64) *Error

NewErrSessionNotFound creates an HTTP error indicating that the requested session ID was not found amongst the active sessions.

func NewErrStepperFailedToSetPolicy

func NewErrStepperFailedToSetPolicy() *Error

NewErrStepperFailedToSetPolicy indicates that an error occurred while setting the new policy. This most likely is due to an ETag mismatch.

func NewErrTorNotFound

func NewErrTorNotFound(rackId string, torID int64) *Error

NewErrTorNotFound indicates that the rack was found but no tor was found

func NewErrUserAlreadyExists

func NewErrUserAlreadyExists(name string) *Error

NewErrUserAlreadyExists indicates the specified user account was previously created and the request was determined to be a duplicate Create request.

func NewErrUserInvalidOperation

func NewErrUserInvalidOperation(op string, user string) *Error

NewErrUserInvalidOperation indicates the operation requested for the supplied user account is invalid in some way, likely a non-existent operation code.

func NewErrUserNotFound

func NewErrUserNotFound(name string) *Error

NewErrUserNotFound indicates the specified user account was determined to not exist (i.e. the search succeeded but no record was found)

func NewErrUserPermissionDenied

func NewErrUserPermissionDenied() *Error

NewErrUserPermissionDenied indicates the user does not have the appropriate permissions for the requested operation.

func NewErrUserProtected

func NewErrUserProtected(name string) *Error

NewErrUserProtected indicates that the user entry may not be deleted.

func NewErrUserStaleVersion

func NewErrUserStaleVersion(name string) *Error

NewErrUserStaleVersion indicates that an operation against the specified user expected a different revision number than was found

func NewErrZoneNotFound

func NewErrZoneNotFound(name string) *Error

NewErrZoneNotFound indicates the specified zone does not exist and the http request (http.statusNotFound) determines to be the request was made against a non-existing zone.

func (*Error) Error

func (he *Error) Error() string

func (*Error) StatusCode

func (he *Error) StatusCode() int

StatusCode is used to extract a status from a standard Error

Jump to

Keyboard shortcuts

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