Documentation ¶
Index ¶
- func JSONToProto(channel *Channel) (protoChan *protoed.Channel)
- func SetupRouter(h Handler) *mux.Router
- func ValidateAgainstChannelSchema(bb []byte) error
- func ValidateAgainstChannelsPageSchema(bb []byte) error
- func ValidateAgainstDescriptorSchema(bb []byte) error
- func ValidateAgainstEntitySchema(bb []byte) error
- func ValidateAgainstTokenSchema(bb []byte) error
- func WrapDeleteChannel(h Handler, w http.ResponseWriter, r *http.Request)
- func WrapListChannels(h Handler, w http.ResponseWriter, r *http.Request)
- func WrapPutChannel(h Handler, w http.ResponseWriter, r *http.Request)
- type Channel
- type ChannelsPage
- type Descriptor
- type Entity
- type Handler
- type HandlerImpl
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONToProto ¶
JSONToProto converts a parsed JSON channel to the protobuf channel representation.
JSONToProto requires: * channel != nil
JSONToProto ensures: * protoChan != nil
func SetupRouter ¶
SetupRouter sets up a router. If you don't use any middleware, you are good to go. Otherwise, you need to maually re-implement this function with your middlewares.
func ValidateAgainstChannelSchema ¶
ValidateAgainstChannelSchema validates a message coming from the client against Channel schema.
func ValidateAgainstChannelsPageSchema ¶
ValidateAgainstChannelsPageSchema validates a message coming from the client against ChannelsPage schema.
func ValidateAgainstDescriptorSchema ¶
ValidateAgainstDescriptorSchema validates a message coming from the client against Descriptor schema.
func ValidateAgainstEntitySchema ¶
ValidateAgainstEntitySchema validates a message coming from the client against Entity schema.
func ValidateAgainstTokenSchema ¶
ValidateAgainstTokenSchema validates a message coming from the client against Token schema.
func WrapDeleteChannel ¶
func WrapDeleteChannel(h Handler, w http.ResponseWriter, r *http.Request)
WrapDeleteChannel wraps the path `/api/channel` with the method "delete"
Path description: removes the channel associated with the descriptor.
func WrapListChannels ¶
func WrapListChannels(h Handler, w http.ResponseWriter, r *http.Request)
WrapListChannels wraps the path `/api/list_channels` with the method "get"
Path description: lists the available channels information.
func WrapPutChannel ¶
func WrapPutChannel(h Handler, w http.ResponseWriter, r *http.Request)
WrapPutChannel wraps the path `/api/channel` with the method "put"
Path description: Updates the channel uniquely identified by a descriptor.
If there is already a channel associated with the descriptor, the old channel is overwritten with the new one.
In order to enforce the min_period between messages, the Relay server keeps track of the time of the most recently relayed message for each descriptor. If a channel is overwritten, the time of relay of the most recent message is erased unless the new channel has the same min_period field as the old one.
Types ¶
type Channel ¶
type Channel struct { Descriptor Descriptor `json:"descriptor"` Token Token `json:"token"` Sender Entity `json:"sender"` Recipients []Entity `json:"recipients"` Cc []Entity `json:"cc,omitempty"` Bcc []Entity `json:"bcc,omitempty"` // indicates the MailGun domain for the channel. Domain string `json:"domain"` // is the minimum push period frequency for a channel, in seconds. MinPeriod float32 `json:"min_period"` // indicates the maximum allowed size of the request, in bytes. MaxSize int32 `json:"max_size"` }
Channel defines the messaging channel.
func ProtoToJSON ¶
ProtoToJSON converts a protobuf channel to the parsed JSON channel representation.
ProtoToJSON requires: * channel != nil
ProtoToJSON ensures: * jsonChan != nil
type ChannelsPage ¶
type ChannelsPage struct { // specifies the index of the page. Page int32 `json:"page"` // specifies the number of pages available. PageCount int32 `json:"page_count"` // specifies the number of items per page. PerPage int32 `json:"per_page"` // contains the channel data. Channels []Channel `json:"channels"` }
ChannelsPage lists channels in a paginated manner.
type Handler ¶
type Handler interface { // PutChannel handles the path `/api/channel` with the method "put". // // Path description: // Updates the channel uniquely identified by a descriptor. // // If there is already a channel associated with the descriptor, the old channel is overwritten with the new one. // // In order to enforce the min_period between messages, the Relay server keeps track of the time of the most // recently relayed message for each descriptor. If a channel is overwritten, the time of relay of the most // recent message is erased unless the new channel has the same min_period field as the old one. PutChannel(w http.ResponseWriter, r *http.Request, channel Channel) // DeleteChannel handles the path `/api/channel` with the method "delete". // // Path description: // removes the channel associated with the descriptor. DeleteChannel(w http.ResponseWriter, r *http.Request, descriptor Descriptor) // ListChannels handles the path `/api/list_channels` with the method "get". // // Path description: // lists the available channels information. ListChannels(w http.ResponseWriter, r *http.Request, page *int32, perPage *int32) }
Handler defines an interface to handling the routes.
type HandlerImpl ¶
HandlerImpl implements the Handler.
func (*HandlerImpl) DeleteChannel ¶
func (h *HandlerImpl) DeleteChannel(w http.ResponseWriter, r *http.Request, descriptor Descriptor)
DeleteChannel implements Handler.DeleteChannel.
func (*HandlerImpl) ListChannels ¶
func (h *HandlerImpl) ListChannels(w http.ResponseWriter, r *http.Request, page *int32, perPage *int32)
ListChannels implements Handler.ListChannels.
func (*HandlerImpl) PutChannel ¶
func (h *HandlerImpl) PutChannel(w http.ResponseWriter, r *http.Request, channel Channel)
PutChannel implements Handler.PutChannel.