Documentation ¶
Index ¶
- func DecodeAndValidateForm(form interface{}, r *http.Request) error
- func DecodeAndValidateJSON(envelope interface{}, r *http.Request) error
- func DecodeAndValidateQueryParams(form interface{}, r *http.Request) error
- func DecodePossibleBase64(original string) string
- func NameFromFirstLastUsername(first string, last string, username string) string
- func RunChannelBenchmarks(b *testing.B, channels []courier.Channel, handler courier.ChannelHandler, ...)
- func RunChannelSendTestCases(t *testing.T, channel courier.Channel, handler courier.ChannelHandler, ...)
- func RunChannelTestCases(t *testing.T, channels []courier.Channel, handler courier.ChannelHandler, ...)
- func Sp(str string) *string
- func Tp(tm time.Time) *time.Time
- func Validate(form interface{}) error
- type BaseHandler
- type ChannelHandleTestCase
- type ChannelSendTestCase
- type RequestPrepFunc
- type SendPrepFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeAndValidateForm ¶
DecodeAndValidateForm takes the passed in form and attempts to parse and validate it from the POST parameters of the passed in request
func DecodeAndValidateJSON ¶
DecodeAndValidateJSON takes the passed in envelope and tries to unmarshal it from the body of the passed in request, then validating it
func DecodeAndValidateQueryParams ¶
DecodeAndValidateQueryParams takes the passed in form and attempts to parse and validate it from the GET parameters of the passed in request
func DecodePossibleBase64 ¶
DecodePossibleBase64 detects and decodes a possibly base64 encoded messages by doing:
- check it's at least 60 characters
- check its length is divisible by 4
- check that there's no whitespace
- check the decoded string contains at least 50% ascii
func NameFromFirstLastUsername ¶
NameFromFirstLastUsername is a utility function to build a contact's name from the passed in values, all of which can be empty
func RunChannelBenchmarks ¶
func RunChannelBenchmarks(b *testing.B, channels []courier.Channel, handler courier.ChannelHandler, testCases []ChannelHandleTestCase)
RunChannelBenchmarks runs all the passed in test cases for the passed in channels
func RunChannelSendTestCases ¶ added in v0.2.0
func RunChannelSendTestCases(t *testing.T, channel courier.Channel, handler courier.ChannelHandler, testCases []ChannelSendTestCase)
RunChannelSendTestCases runs all the passed in test cases against the channel
func RunChannelTestCases ¶
func RunChannelTestCases(t *testing.T, channels []courier.Channel, handler courier.ChannelHandler, testCases []ChannelHandleTestCase)
RunChannelTestCases runs all the passed in tests cases for the passed in channel configurations
Types ¶
type BaseHandler ¶
type BaseHandler struct {
// contains filtered or unexported fields
}
BaseHandler is the base class for most handlers, it just stored the server, name and channel type for the handler
func NewBaseHandler ¶
func NewBaseHandler(channelType courier.ChannelType, name string) BaseHandler
NewBaseHandler returns a newly constructed BaseHandler with the passed in parameters
func (*BaseHandler) Backend ¶ added in v0.2.0
func (h *BaseHandler) Backend() courier.Backend
Backend returns the backend instance on the BaseHandler
func (*BaseHandler) ChannelName ¶
func (h *BaseHandler) ChannelName() string
ChannelName returns the name of the channel this handler deals with
func (*BaseHandler) ChannelType ¶
func (h *BaseHandler) ChannelType() courier.ChannelType
ChannelType returns the channel type that this handler deals with
func (*BaseHandler) Server ¶
func (h *BaseHandler) Server() courier.Server
Server returns the server instance on the BaseHandler
func (*BaseHandler) SetServer ¶
func (h *BaseHandler) SetServer(server courier.Server)
SetServer can be used to change the server on a BaseHandler
type ChannelHandleTestCase ¶ added in v0.2.0
type ChannelHandleTestCase struct { Label string URL string Data string Status int Response string Name *string Text *string URN *string Attachment *string Attachments []string Date *time.Time ChannelEvent *string ExternalID *string ID int64 PrepRequest RequestPrepFunc }
ChannelHandleTestCase defines the test values for a particular test case
type ChannelSendTestCase ¶ added in v0.2.0
type ChannelSendTestCase struct { Label string Text string URN string Attachments []string Priority courier.MsgPriority ResponseStatus int ResponseBody string Path string URLParams map[string]string PostParams map[string]string RequestBody string Headers map[string]string Error string Status string ExternalID string Stopped bool SendPrep SendPrepFunc }
ChannelSendTestCase defines the test values for a particular test case
type RequestPrepFunc ¶
RequestPrepFunc is our type for a hook for tests to use before a request is fired in a test