handlers

package
v0.0.0-...-c407d37 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OfficeTestHost
	OfficeTestHost string = "office.example.com"
	// MilTestHost
	MilTestHost string = "mil.example.com"
	// OrdersTestHost
	OrdersTestHost string = "orders.example.com"
	// AdminTestHost
	AdminTestHost string = "admin.example.com"
	// PrimeTestHost
	PrimeTestHost string = "prime.example.com"
)
View Source
const BadRequestErrMessage string = "Bad Request"

BadRequestErrMessage indicates that the request was malformed

View Source
const ConflictErrMessage string = "Conflict Error"

ConflictErrMessage indicates that there was a conflict with input values

View Source
const ForbiddenErrMessage string = "Forbidden"

ForbiddenErrMessage indicates the caller is forbidden

View Source
const InternalServerErrDetail string = "An internal server error has occurred"

InternalServerErrDetail provides a default detail string

View Source
const InternalServerErrMessage string = "Internal Server Error"

InternalServerErrMessage indicates that there was an internal server error

View Source
const MethodNotAllowedErrMessage string = "Method Not Allowed"

MethodNotAllowedErrMessage indicates that the particular http request method was not allowed

View Source
const NilErrMessage string = "Nil error passed"

NilErrMessage indicates an uninstantiated error was passed

View Source
const NotAcceptableErrMessage string = "Not Acceptable"

NotAcceptableErrMessage indicates the server does not accept the media type requested

View Source
const NotFoundMessage string = "Not Found Error"

NotFoundMessage indicates a resource was not found

View Source
const NotImplementedErrDetail string = "This feature is in development"

NotImplementedErrDetail indicates an endpoint has not been implemented

View Source
const NotImplementedErrMessage string = "Not Implemented"

NotImplementedErrMessage indicates an endpoint has not been implemented

View Source
const PreconditionErrMessage string = "Precondition Failed"

PreconditionErrMessage indicates that the IfMatch header (eTag) was stale

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

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

View Source
const ServiceUnavailableErrMessage string = "Service Unavailable"

ServiceUnavailableErrMessage indicates the service is currently unavailable

View Source
const UnauthorizedErrMessage string = "Unauthorized"

UnauthorizedErrMessage indicates the caller is not authorized

View Source
const UnsupportedMediaTypeErrMessage string = "Unsupported Media Type"

UnsupportedMediaTypeErrMessage indicates the server does not accept the media type sent

View Source
const ValidationErrMessage string = "Validation Error"

ValidationErrMessage indicates that some fields were invalid

Variables

This section is empty.

Functions

func ApplicationTestServername

func ApplicationTestServername() auth.ApplicationServername

ApplicationTestServername is a collection of the test servernames

func FmtBool

func FmtBool(b bool) *bool

FmtBool converts pop type to go-swagger type

func FmtCost

func FmtCost(c *unit.Cents) *int64

FmtCost 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 FmtDatePtrToPop

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

FmtDatePtrToPopPtr converts go-swagger type to pop 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 FmtDateTimePtrToPop

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

FmtDateTimePtrToPop converts go-swagger type time to pop time

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 FmtInt

func FmtInt(i int) *int

FmtInt converts an int to an int pointer

func FmtInt64

func FmtInt64(i int64) *int64

FmtInt64 converts pop type to go-swagger type

func FmtInt64PtrToPopPtr

func FmtInt64PtrToPopPtr(c *int64) *unit.Cents

FmtInt64PtrToPopPtr converts go-swagger type to pop type

func FmtIntPtrToInt64

func FmtIntPtrToInt64(i *int) *int64

FmtIntPtrToInt64 converts pop type to go-swagger type

func FmtMilliCentsPtr

func FmtMilliCentsPtr(c *unit.Millicents) *int64

FmtMilliCentsPtr converts pop type to go-swagger type

func FmtNullableStringToStringPtrNilToBlankString

func FmtNullableStringToStringPtrNilToBlankString(n nullable.String) *string

FmtNullableStringToStringPtrNilToBlankString converts go-swagger nullable string type to a string pointer type. If the value is nil, it returns a pointer to an empty string. This can be useful for updating models so that the service object knows to blank out the field.

func FmtNullableStringToStringPtrNilToNil

func FmtNullableStringToStringPtrNilToNil(n nullable.String) *string

FmtNullableStringToStringPtrNilToNil converts go-swagger nullable string type to a string pointer type. If the value is nil, it returns nil. This can be useful for when we create a new model instance and don't want blank string values to be saved to the database.

func FmtPoundPtr

func FmtPoundPtr(weight *unit.Pound) *int64

FmtPoundPtr 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 FmtUUIDPtrToPopPtr

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

FmtUUIDPtrToPopPtr converts go-swagger uuid type to pop type

func FmtUUIDToPop

func FmtUUIDToPop(u strfmt.UUID) uuid.UUID

FmtUUIDToPop converts go-swagger uuid type to pop type

func FmtUUIDValue

func FmtUUIDValue(u uuid.UUID) strfmt.UUID

FmtUUIDValue converts pop UUID value type to go-swagger UUID value type

func NewClientLogHandler

func NewClientLogHandler(appCtx appcontext.AppContext) http.HandlerFunc

NewClientLogHandler creates a handler for receiving client logs

func NewCookieUpdateResponder

func NewCookieUpdateResponder(request *http.Request, responder middleware.Responder, sessionManager auth.SessionManager, session *auth.Session) middleware.Responder

NewCookieUpdateResponder constructs a wrapper for the responder which will update cookies

func NewFileHandler

func NewFileHandler(fs afero.Fs, entrypoint string) http.HandlerFunc

NewFileHandler serves up a single file from a custom filesystem. Use the custom filesystem for ease of testing

func NewHealthHandler

func NewHealthHandler(appCtx appcontext.AppContext, redisPool *redis.Pool, gitBranch string, gitCommit string) http.HandlerFunc

NewHealthHandler creates a http.HandlerFunc for a health endpoint. If redisPool is nil, redis health will not be checked

func PoundPtrFromInt64Ptr

func PoundPtrFromInt64Ptr(num *int64) *unit.Pound

PoundPtrFromInt64Ptr converts go-swagger type to pop type

func ResponseForConflictErrors

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

ResponseForConflictErrors checks for conflict errors

func ResponseForCustomErrors

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

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

func ResponseForError

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

ResponseForError logs an error and returns the expected error type

func ResponseForVErrors

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

ResponseForVErrors checks for validation errors

func ServeCustomError

func ServeCustomError(rw http.ResponseWriter, r *http.Request, err error)

ServeCustomError is called by a hook provided by openapi to handle errors generated by that package. We override it below so that we can populate the title, detail, instance into the payload to match Milmove's desired error format.

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 AuditableAppContextBasicHandler

type AuditableAppContextBasicHandler func(appCtx appcontext.AppContext, w http.ResponseWriter, r *http.Request) error

type BaseHandlerTestSuite

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

BaseHandlerTestSuite abstracts the common methods needed for handler tests

func NewBaseHandlerTestSuite

NewBaseHandlerTestSuite returns a new BaseHandlerTestSuite

func (*BaseHandlerTestSuite) AuthenticateAdminRequest

func (suite *BaseHandlerTestSuite) AuthenticateAdminRequest(req *http.Request, user models.User) *http.Request

AuthenticateAdminRequest authenticates Admin users

func (*BaseHandlerTestSuite) AuthenticateOfficeRequest

func (suite *BaseHandlerTestSuite) AuthenticateOfficeRequest(req *http.Request, user models.OfficeUser) *http.Request

AuthenticateOfficeRequest authenticates Office users

func (*BaseHandlerTestSuite) AuthenticateRequest

func (suite *BaseHandlerTestSuite) AuthenticateRequest(req *http.Request, serviceMember models.ServiceMember) *http.Request

AuthenticateRequest Request authenticated with a service member

func (*BaseHandlerTestSuite) AuthenticateUserRequest

func (suite *BaseHandlerTestSuite) AuthenticateUserRequest(req *http.Request, user models.User) *http.Request

AuthenticateUserRequest only authenticated with a bare user - have no idea if they are a service member yet

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) EqualCentsPointers

func (suite *BaseHandlerTestSuite) EqualCentsPointers(expected *unit.Cents, actual *int64)

EqualCentsPointers compares the unit.Cent from the model with the int64 from the payload If one is nil, both should be nil, else they should match in value

func (*BaseHandlerTestSuite) EqualDate

func (suite *BaseHandlerTestSuite) EqualDate(expected time.Time, actual strfmt.Date)

EqualDate compares the time.Time from the model with the strfmt.Date from the payload

func (*BaseHandlerTestSuite) EqualDatePtr

func (suite *BaseHandlerTestSuite) EqualDatePtr(expected *time.Time, actual *strfmt.Date)

EqualDatePtr compares the time.Time from the model with the strfmt.date from the payload If one is nil, both should be nil, else they should match in value This is to be strictly used for dates as it drops any time parameters in the comparison

func (*BaseHandlerTestSuite) EqualDateTime

func (suite *BaseHandlerTestSuite) EqualDateTime(expected time.Time, actual strfmt.DateTime)

EqualDateTime compares the time.Time from the model with the strfmt.DateTime from the payload

func (*BaseHandlerTestSuite) EqualDateTimePtr

func (suite *BaseHandlerTestSuite) EqualDateTimePtr(expected *time.Time, actual *strfmt.DateTime)

EqualDateTimePtr compares the time.Time from the model with the strfmt.date from the payload If one is nil, both should be nil, else they should match in value.

func (*BaseHandlerTestSuite) EqualPoundPointers

func (suite *BaseHandlerTestSuite) EqualPoundPointers(expected *unit.Pound, actual *int64)

EqualPoundPointers compares the unit.Pound from the model with the int64 from the payload If one is nil, both should be nil, else they should match in value

func (*BaseHandlerTestSuite) EqualUUID

func (suite *BaseHandlerTestSuite) EqualUUID(expected uuid.UUID, actual strfmt.UUID)

EqualUUID compares the uuid.UUID from the model with the strfmt.UUID from the payload

func (*BaseHandlerTestSuite) EqualUUIDPointers

func (suite *BaseHandlerTestSuite) EqualUUIDPointers(expected *uuid.UUID, actual *strfmt.UUID)

EqualUUIDPointers compares the uuid.UUID from the model with the strfmt.UUID from the payload If one is nil, both should be nil, else they should match in value

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) HandlerConfig

func (suite *BaseHandlerTestSuite) HandlerConfig() *Config

HandlerConfig returns a mostly empty handler config for testing. NOTE: it returns the Config implementation, not the HandlerConfig interface, so overrides can be made to the config

func (*BaseHandlerTestSuite) HasNoWebhookNotification

func (suite *BaseHandlerTestSuite) HasNoWebhookNotification(objectID uuid.UUID, traceID uuid.UUID)

HasNoWebhookNotification checks that there's no record on the WebhookNotifications table for the object and trace IDs

func (*BaseHandlerTestSuite) HasWebhookNotification

func (suite *BaseHandlerTestSuite) HasWebhookNotification(objectID uuid.UUID, traceID uuid.UUID)

HasWebhookNotification checks that there's a record on the WebhookNotifications table for the object and trace IDs

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) TestNotificationSender

func (suite *BaseHandlerTestSuite) TestNotificationSender() notifications.NotificationSender

TestNotificationSender returns the notification sender to use in the suite

type ClientLogEntry

type ClientLogEntry struct {
	Level string           `json:"level"`
	Args  ClientLogMessage `json:"args"`
}

type ClientLogMessage

type ClientLogMessage []interface{}

type ClientLogUpload

type ClientLogUpload struct {
	App         string            `json:"app"`
	LoggerStats ClientLoggerStats `json:"loggerStats"`
	LogEntries  []ClientLogEntry  `json:"logEntries"`
}

type ClientLoggerStats

type ClientLoggerStats struct {
	DroppedLogsCount int `json:"droppedLogsCount"`
	FailedSendCount  int `json:"failedSendCount"`
	FailedTimerCount int `json:"failedTimerCount"`
}

type Config

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

A single Config is passed to each handler. This should be instantiated by NewHandlerConfig

func (*Config) AppContextFromRequest

func (c *Config) AppContextFromRequest(r *http.Request) appcontext.AppContext

AppContextFromRequest builds an AppContext from the http request TODO: This should eventually go away and all handlers should use AuditableAppContextFromRequestWithErrors

func (*Config) AppNames

func (c *Config) AppNames() auth.ApplicationServername

AppNames returns a struct of all the app names for the current environment

func (*Config) AuditableAppContextFromRequestBasicHandler

func (c *Config) AuditableAppContextFromRequestBasicHandler(
	handler AuditableAppContextBasicHandler,
) http.Handler

AuditableAppContextFromRequestBasicHandler creates a transaction and sets local variables for use by the auditable trigger and also allows handlers to return errors.

func (*Config) AuditableAppContextFromRequestWithErrors

func (c *Config) AuditableAppContextFromRequestWithErrors(
	r *http.Request,
	handler func(appCtx appcontext.AppContext) (middleware.Responder, error),
) middleware.Responder

AuditableAppContextFromRequestWithErrors creates a transaction and sets local variables for use by the auditable trigger and also allows handlers to return errors.

func (*Config) CookieSecret

func (c *Config) CookieSecret() string

CookieSecret returns the secret key to use when signing cookies

func (*Config) DTODPlanner

func (c *Config) DTODPlanner() route.Planner

DTODPlanner returns the DTOD planner for the current context

func (*Config) FeatureFlagFetcher

func (c *Config) FeatureFlagFetcher() services.FeatureFlagFetcher

FeatureFlagFetcher returns the feature flag fetching service

func (*Config) FileStorer

func (c *Config) FileStorer() storage.FileStorer

FileStorer returns the storage to use in the current context

func (*Config) GetTraceIDFromRequest

func (c *Config) GetTraceIDFromRequest(r *http.Request) uuid.UUID

GetTraceIDFromRequest returns the request traceID. It returns the Nil UUID if no traceid is found

func (*Config) GexSender

func (c *Config) GexSender() services.GexSender

func (*Config) HHGPlanner

func (c *Config) HHGPlanner() route.Planner

HHGPlanner returns the HHG planner for the current context

func (*Config) ICNSequencer

func (c *Config) ICNSequencer() sequence.Sequencer

func (*Config) IWSPersonLookup

func (c *Config) IWSPersonLookup() iws.PersonLookup

func (*Config) NotificationSender

func (c *Config) NotificationSender() notifications.NotificationSender

NotificationSender returns the sender to use in the current context

func (*Config) SendProductionInvoice

func (c *Config) SendProductionInvoice() bool

SendProductionInvoice is a flag to notify EDI invoice generation whether it should be sent as a test or production transaction

func (*Config) SessionManagers

func (c *Config) SessionManagers() auth.AppSessionManagers

SessionManagers returns the auth AppSessionManagers

func (*Config) SetAppNames

func (c *Config) SetAppNames(appNames auth.ApplicationServername)

SetAppNames is a simple setter for private field

func (*Config) SetCookieSecret

func (c *Config) SetCookieSecret(cookieSecret string)

SetCookieSecret is a simple setter for the cookieSeecret private Field

func (*Config) SetDTODPlanner

func (c *Config) SetDTODPlanner(planner route.Planner)

SetDTODPlanner is a simple setter for the route.Planner private field

func (*Config) SetFeatureFlagFetcher

func (c *Config) SetFeatureFlagFetcher(fff services.FeatureFlagFetcher)

SetFeatureFlagFetcher sets the feature flag fetcher

func (*Config) SetFileStorer

func (c *Config) SetFileStorer(storer storage.FileStorer)

SetFileStorer is a simple setter for storage private field

func (*Config) SetGexSender

func (c *Config) SetGexSender(sendGexRequest services.GexSender)

func (*Config) SetHHGPlanner

func (c *Config) SetHHGPlanner(planner route.Planner)

SetHHGPlanner is a simple setter for the route.Planner private field

func (*Config) SetICNSequencer

func (c *Config) SetICNSequencer(sequencer sequence.Sequencer)

func (*Config) SetIWSPersonLookup

func (c *Config) SetIWSPersonLookup(rbs iws.PersonLookup)

func (*Config) SetNotificationSender

func (c *Config) SetNotificationSender(sender notifications.NotificationSender)

SetNotificationSender is a simple setter for AWS SES private field

func (*Config) SetPlanner

func (c *Config) SetPlanner(planner route.Planner)

SetPlanner is a simple setter for the route.Planner private field

func (*Config) SetSendProductionInvoice

func (c *Config) SetSendProductionInvoice(sendProductionInvoice bool)

Set UsageIndicator flag for use in EDI invoicing (ediinvoice pkg)

func (*Config) SetUseSecureCookie

func (c *Config) SetUseSecureCookie(useSecureCookie bool)

Sets flag for using Secure cookie

func (*Config) UseSecureCookie

func (c *Config) UseSecureCookie() bool

UseSecureCookie determines if the field "Secure" is set to true or false upon cookie creation

type CookieUpdateResponder

type CookieUpdateResponder struct {
	Responder middleware.Responder
	// contains filtered or unexported fields
}

CookieUpdateResponder wraps a swagger middleware.Responder in code which sets the session_cookie See: https://github.com/go-swagger/go-swagger/issues/748

func (*CookieUpdateResponder) WriteResponse

func (cur *CookieUpdateResponder) WriteResponse(rw http.ResponseWriter, p runtime.Producer)

WriteResponse updates the session cookie before writing out the details of the response

type CustomFileSystem

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

from https://www.alexedwards.net/blog/disable-http-fileserver-directory-listings

func NewCustomFileSystem

func NewCustomFileSystem(fs http.FileSystem, indexPath string, logger *zap.Logger) CustomFileSystem

func (CustomFileSystem) Open

func (cfs CustomFileSystem) Open(path string) (http.File, error)

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, _ runtime.Producer)

WriteResponse to the client

type HandlerConfig

type HandlerConfig interface {
	AppContextFromRequest(r *http.Request) appcontext.AppContext
	AuditableAppContextFromRequestWithErrors(
		*http.Request,
		func(appCtx appcontext.AppContext) (middleware.Responder, error),
	) middleware.Responder
	AuditableAppContextFromRequestBasicHandler(
		handler AuditableAppContextBasicHandler,
	) http.Handler
	FileStorer() storage.FileStorer
	NotificationSender() notifications.NotificationSender
	HHGPlanner() route.Planner
	DTODPlanner() route.Planner
	CookieSecret() string
	IWSPersonLookup() iws.PersonLookup
	SendProductionInvoice() bool
	UseSecureCookie() bool
	AppNames() auth.ApplicationServername
	SessionManagers() auth.AppSessionManagers

	GexSender() services.GexSender
	ICNSequencer() sequence.Sequencer
	GetTraceIDFromRequest(r *http.Request) uuid.UUID

	FeatureFlagFetcher() services.FeatureFlagFetcher
}

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

func NewHandlerConfig

func NewHandlerConfig(
	db *pop.Connection,
	logger *zap.Logger,
	cookieSecret string,
	hhgPlanner route.Planner,
	dtodPlanner route.Planner,
	storage storage.FileStorer,
	notificationSender notifications.NotificationSender,
	iwsPersonLookup iws.PersonLookup,
	sendProductionInvoice bool,
	senderToGex services.GexSender,
	icnSequencer sequence.Sequencer,
	useSecureCookie bool,
	appNames auth.ApplicationServername,
	sessionManagers auth.AppSessionManagers,
	featureFlagFetcher services.FeatureFlagFetcher,
) HandlerConfig

NewHandlerConfig returns a new HandlerConfig interface with its required private fields set.

type SpaHandler

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

SpaHandler implements the http.Handler interface, so we can use it to respond to HTTP requests. The path to the static directory and path to the index file within that static directory are used to serve the SPA in the given static directory.

func NewSpaHandler

func NewSpaHandler(staticPath string, indexPath string, cfs CustomFileSystem) SpaHandler

NewSpaHandler returns a new handler for a Single Page App

func (SpaHandler) ServeHTTP

func (h SpaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP inspects the URL path to locate a file within the static dir on the SPA handler. If a file is found, it will be served. If not, the file located at the index path on the SPA handler will be served. This is suitable behavior for serving an SPA (single page application).

type ValidationErrorListResponse

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

ValidationErrorListResponse maps field names to a list of errors for the field

func NewValidationErrorListResponse

func NewValidationErrorListResponse(verrs *validate.Errors) *ValidationErrorListResponse

NewValidationErrorListResponse returns a new validations error list response

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 validations errors response

func (*ValidationErrorsResponse) WriteResponse

WriteResponse to the client

Jump to

Keyboard shortcuts

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