Documentation
¶
Index ¶
- Constants
- func FmtBool(b bool) *bool
- func FmtDate(date time.Time) *strfmt.Date
- func FmtDatePtr(date *time.Time) *strfmt.Date
- func FmtDatePtrToPopPtr(date *strfmt.Date) *time.Time
- func FmtDateSlice(dates []time.Time) []strfmt.Date
- func FmtDateTime(dateTime time.Time) *strfmt.DateTime
- func FmtDateTimePtr(dateTime *time.Time) *strfmt.DateTime
- func FmtDateTimePtrToPopPtr(date *strfmt.DateTime) *time.Time
- func FmtEmail(email string) *strfmt.Email
- func FmtEmailPtr(email *string) *strfmt.Email
- func FmtInt64(i int64) *int64
- func FmtIntPtrToInt64(i *int) *int64
- func FmtSSN(s string) *strfmt.SSN
- func FmtString(s string) *string
- func FmtStringPtr(s *string) *string
- func FmtStringPtrNonEmpty(s *string) *string
- func FmtURI(uri string) *strfmt.URI
- func FmtUUID(u uuid.UUID) *strfmt.UUID
- func FmtUUIDPtr(u *uuid.UUID) *strfmt.UUID
- func ResponseForConflictErrors(logger Logger, err error) middleware.Responder
- func ResponseForCustomErrors(logger Logger, err error, httpStatus int) middleware.Responder
- func ResponseForError(logger Logger, err error) middleware.Responder
- func ResponseForVErrors(logger Logger, verrs *validate.Errors, err error) middleware.Responder
- func StringFromEmail(email *strfmt.Email) *string
- func StringFromSSN(ssn *strfmt.SSN) *string
- type BaseHandlerTestSuite
- func (suite *BaseHandlerTestSuite) CheckErrorResponse(resp middleware.Responder, code int, name string)
- func (suite *BaseHandlerTestSuite) CheckNotErrorResponse(resp middleware.Responder)
- func (suite *BaseHandlerTestSuite) CheckResponseBadRequest(resp middleware.Responder)
- func (suite *BaseHandlerTestSuite) CheckResponseForbidden(resp middleware.Responder)
- func (suite *BaseHandlerTestSuite) CheckResponseInternalServerError(resp middleware.Responder)
- func (suite *BaseHandlerTestSuite) CheckResponseNotFound(resp middleware.Responder)
- func (suite *BaseHandlerTestSuite) CheckResponseTeapot(resp middleware.Responder)
- func (suite *BaseHandlerTestSuite) CheckResponseUnauthorized(resp middleware.Responder)
- func (suite *BaseHandlerTestSuite) CloseFile(file *runtime.File)
- func (suite *BaseHandlerTestSuite) Fixture(name string) *runtime.File
- func (suite *BaseHandlerTestSuite) IsNotErrResponse(response middleware.Responder)
- func (suite *BaseHandlerTestSuite) SetTestFilesToClose(filesToClose []*runtime.File)
- func (suite *BaseHandlerTestSuite) TestFilesToClose() []*runtime.File
- func (suite *BaseHandlerTestSuite) TestLogger() Logger
- type ErrResponse
- type FeatureFlag
- type HandlerContext
- type Logger
- type ValidationErrorsResponse
Constants ¶
const NilErrMessage string = "Nil error passed"
NilErrMessage indicates an uninstantiated error was passed
const SQLErrMessage string = "Unhandled SQL error encountered"
SQLErrMessage represents string value to represent generic sql error to avoid leaking implementation details
const ValidationErrMessage string = "Validation Error"
ValidationErrMessage indicates that some fields were invalid
Variables ¶
This section is empty.
Functions ¶
func FmtDatePtr ¶
FmtDatePtr converts pop type to go-swagger type
func FmtDatePtrToPopPtr ¶
FmtDatePtrToPopPtr converts go-swagger type to pop type
func FmtDateSlice ¶
FmtDateSlice converts []time.Time to []strfmt.Date
func FmtDateTime ¶
FmtDateTime converts pop type to go-swagger type
func FmtDateTimePtr ¶
FmtDateTimePtr converts pop type to go-swagger type
func FmtDateTimePtrToPopPtr ¶
FmtDateTimePtrToPopPtr converts go-swagger type to pop type
func FmtEmailPtr ¶
FmtEmailPtr converts pop type to go-swagger type
func FmtIntPtrToInt64 ¶
FmtIntPtrToInt64 converts pop type to go-swagger type
func FmtStringPtr ¶
FmtStringPtr converts pop type to go-swagger type
func FmtStringPtrNonEmpty ¶
FmtStringPtrNonEmpty converts an empty string (after trimming) to a nil.
func FmtUUIDPtr ¶
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 ¶
ResponseForVErrors checks for validation errors
func StringFromEmail ¶
StringFromEmail converts pop type to go-swagger type
func StringFromSSN ¶
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 ¶
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 ¶
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 ¶
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