handlers

package
v0.0.0-...-34c5031 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const NilErrMessage string = "Nil error passed"

NilErrMessage indicates an uninstantiated error was passed

View Source
const SQLErrMessage string = "Unhandled SQL error encountered"

SQLErrMessage represents string value to represent generic sql error to avoid leaking implementation details

View Source
const ValidationErrMessage string = "Validation Error"

ValidationErrMessage indicates that some fields were invalid

Variables

This section is empty.

Functions

func FmtBool

func FmtBool(b bool) *bool

FmtBool converts pop type to go-swagger type

func FmtDate

func FmtDate(date time.Time) *strfmt.Date

FmtDate converts pop type to go-swagger type

func FmtDatePtr

func FmtDatePtr(date *time.Time) *strfmt.Date

FmtDatePtr converts pop type to go-swagger type

func FmtDatePtrToPopPtr

func FmtDatePtrToPopPtr(date *strfmt.Date) *time.Time

FmtDatePtrToPopPtr converts go-swagger type to pop type

func FmtDateSlice

func FmtDateSlice(dates []time.Time) []strfmt.Date

FmtDateSlice converts []time.Time to []strfmt.Date

func FmtDateTime

func FmtDateTime(dateTime time.Time) *strfmt.DateTime

FmtDateTime converts pop type to go-swagger type

func FmtDateTimePtr

func FmtDateTimePtr(dateTime *time.Time) *strfmt.DateTime

FmtDateTimePtr converts pop type to go-swagger type

func FmtDateTimePtrToPopPtr

func FmtDateTimePtrToPopPtr(date *strfmt.DateTime) *time.Time

FmtDateTimePtrToPopPtr converts go-swagger type to pop type

func FmtEmail

func FmtEmail(email string) *strfmt.Email

FmtEmail converts pop type to go-swagger type

func FmtEmailPtr

func FmtEmailPtr(email *string) *strfmt.Email

FmtEmailPtr converts pop type to go-swagger type

func FmtInt64

func FmtInt64(i int64) *int64

FmtInt64 converts pop type to go-swagger type

func FmtIntPtrToInt64

func FmtIntPtrToInt64(i *int) *int64

FmtIntPtrToInt64 converts pop type to go-swagger type

func FmtSSN

func FmtSSN(s string) *strfmt.SSN

FmtSSN converts pop type to go-swagger type

func FmtString

func FmtString(s string) *string

FmtString converts pop type to go-swagger type

func FmtStringPtr

func FmtStringPtr(s *string) *string

FmtStringPtr converts pop type to go-swagger type

func FmtStringPtrNonEmpty

func FmtStringPtrNonEmpty(s *string) *string

FmtStringPtrNonEmpty converts an empty string (after trimming) to a nil.

func FmtURI

func FmtURI(uri string) *strfmt.URI

FmtURI converts pop type to go-swagger type

func FmtUUID

func FmtUUID(u uuid.UUID) *strfmt.UUID

FmtUUID converts pop type to go-swagger type

func FmtUUIDPtr

func FmtUUIDPtr(u *uuid.UUID) *strfmt.UUID

FmtUUIDPtr converts pop type to go-swagger type

func ResponseForConflictErrors

func ResponseForConflictErrors(logger Logger, err error) middleware.Responder

ResponseForConflictErrors checks for conflict errors

func ResponseForCustomErrors

func ResponseForCustomErrors(logger Logger, err error, httpStatus int) middleware.Responder

ResponseForCustomErrors checks for custom errors and returns a custom response body message

func ResponseForError

func ResponseForError(logger Logger, err error) middleware.Responder

ResponseForError logs an error and returns the expected error type

func ResponseForVErrors

func ResponseForVErrors(logger Logger, verrs *validate.Errors, err error) middleware.Responder

ResponseForVErrors checks for validation errors

func StringFromEmail

func StringFromEmail(email *strfmt.Email) *string

StringFromEmail converts pop type to go-swagger type

func StringFromSSN

func StringFromSSN(ssn *strfmt.SSN) *string

StringFromSSN converts pop type to go-swagger type

Types

type BaseHandlerTestSuite

type BaseHandlerTestSuite struct {
	testingsuite.PopTestSuite
	// contains filtered or unexported fields
}

BaseHandlerTestSuite abstracts the common methods needed for handler tests

func NewBaseHandlerTestSuite

func NewBaseHandlerTestSuite(logger Logger, packageName testingsuite.PackageName) BaseHandlerTestSuite

NewBaseHandlerTestSuite returns a new BaseHandlerTestSuite

func (*BaseHandlerTestSuite) CheckErrorResponse

func (suite *BaseHandlerTestSuite) CheckErrorResponse(resp middleware.Responder, code int, name string)

CheckErrorResponse verifies error response is what is expected

func (*BaseHandlerTestSuite) CheckNotErrorResponse

func (suite *BaseHandlerTestSuite) CheckNotErrorResponse(resp middleware.Responder)

CheckNotErrorResponse verifies there is no error response

func (*BaseHandlerTestSuite) CheckResponseBadRequest

func (suite *BaseHandlerTestSuite) CheckResponseBadRequest(resp middleware.Responder)

CheckResponseBadRequest looks at BadRequest errors

func (*BaseHandlerTestSuite) CheckResponseForbidden

func (suite *BaseHandlerTestSuite) CheckResponseForbidden(resp middleware.Responder)

CheckResponseForbidden looks at Forbidden errors

func (*BaseHandlerTestSuite) CheckResponseInternalServerError

func (suite *BaseHandlerTestSuite) CheckResponseInternalServerError(resp middleware.Responder)

CheckResponseInternalServerError looks at InternalServerError errors

func (*BaseHandlerTestSuite) CheckResponseNotFound

func (suite *BaseHandlerTestSuite) CheckResponseNotFound(resp middleware.Responder)

CheckResponseNotFound looks at NotFound errors

func (*BaseHandlerTestSuite) CheckResponseTeapot

func (suite *BaseHandlerTestSuite) CheckResponseTeapot(resp middleware.Responder)

CheckResponseTeapot enforces that response come from a Teapot

func (*BaseHandlerTestSuite) CheckResponseUnauthorized

func (suite *BaseHandlerTestSuite) CheckResponseUnauthorized(resp middleware.Responder)

CheckResponseUnauthorized looks at Unauthorized errors

func (*BaseHandlerTestSuite) CloseFile

func (suite *BaseHandlerTestSuite) CloseFile(file *runtime.File)

CloseFile adds a single file to close at the end of tests to the list of files

func (*BaseHandlerTestSuite) Fixture

func (suite *BaseHandlerTestSuite) Fixture(name string) *runtime.File

Fixture allows us to include a fixture like a PDF in the test

func (*BaseHandlerTestSuite) IsNotErrResponse

func (suite *BaseHandlerTestSuite) IsNotErrResponse(response middleware.Responder)

IsNotErrResponse enforces handler does not return an error response

func (*BaseHandlerTestSuite) SetTestFilesToClose

func (suite *BaseHandlerTestSuite) SetTestFilesToClose(filesToClose []*runtime.File)

SetTestFilesToClose sets the list of files needed to close at the end of tests

func (*BaseHandlerTestSuite) TestFilesToClose

func (suite *BaseHandlerTestSuite) TestFilesToClose() []*runtime.File

TestFilesToClose returns the list of files needed to close at the end of tests

func (*BaseHandlerTestSuite) TestLogger

func (suite *BaseHandlerTestSuite) TestLogger() Logger

TestLogger returns the logger to use in the suite

type ErrResponse

type ErrResponse struct {
	Code int
	Err  error
}

ErrResponse collect errors and error codes

func (*ErrResponse) WriteResponse

func (o *ErrResponse) WriteResponse(rw http.ResponseWriter, producer runtime.Producer)

WriteResponse to the client

type FeatureFlag

type FeatureFlag struct {
	Name   string
	Active bool
}

FeatureFlag struct for feature flags

type HandlerContext

type HandlerContext interface {
	DB() *pop.Connection
	LoggerFromContext(ctx context.Context) Logger
	LoggerFromRequest(r *http.Request) Logger
	IWSPersonLookup() iws.PersonLookup
	SetIWSPersonLookup(rbs iws.PersonLookup)
	SetAppNames(appNames auth.ApplicationServername)
	AppNames() auth.ApplicationServername
	SetTraceID(traceID uuid.UUID)
	GetTraceID() uuid.UUID
}

HandlerContext provides access to all the contextual references needed by individual handlers

func NewHandlerContext

func NewHandlerContext(db *pop.Connection, logger Logger) HandlerContext

NewHandlerContext returns a new handlerContext with its required private fields set.

type Logger

type Logger interface {
	Debug(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
	Warn(msg string, fields ...zap.Field)
	Fatal(msg string, fields ...zap.Field)
	WithOptions(opts ...zap.Option) *zap.Logger
}

Logger is an interface that describes the logging requirements of this package.

type ValidationErrorsResponse

type ValidationErrorsResponse struct {
	Errors map[string]string `json:"errors,omitempty"`
}

ValidationErrorsResponse is a middleware.Responder for a set of validation errors

func NewValidationErrorsResponse

func NewValidationErrorsResponse(verrs *validate.Errors) *ValidationErrorsResponse

NewValidationErrorsResponse returns a new validation errors response object

func (*ValidationErrorsResponse) WriteResponse

func (v *ValidationErrorsResponse) WriteResponse(rw http.ResponseWriter, producer runtime.Producer)

WriteResponse to the client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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