Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // NotFound : Error message for not found errors NotFound = ErrorMessage{Message: "Not found", Code: "404"} // Unexpected : Error message for unexpected errors Unexpected = ErrorMessage{Message: "Unexpected error", Code: "500"} )
Functions ¶
This section is empty.
Types ¶
type ErrorMessage ¶
ErrorMessage : Struct representing an error message
func (*ErrorMessage) Encoded ¶
func (e *ErrorMessage) Encoded() []byte
Encoded : represent ErrorMessage as a json string
type Handler ¶
type Handler struct {
Nats *nats.Conn
NewModel func() Model
NotFoundErrorMessage []byte
UnexpectedErrorMessage []byte
DeletedMessage []byte
}
Handler : this struct manages all nats connections and maps them to the injected entity
func (*Handler) Del ¶
Del : Based on a json input with an id field will delete the client details for this id
func (*Handler) Find ¶
Find : Based on the fields of the input json it will search and return any entity matching these fields
type Model ¶
type Model interface {
MapInput(body []byte)
LoadFromInput(msg []byte) bool
LoadFromInputOrFail(msg *nats.Msg, h *Handler) bool
Update(body []byte) error
Delete() error
Save() error
Find() []interface{}
HasID() bool
}
Model : This is the interface you need to implement in order to inject a db manager to the Handler