Documentation ¶
Index ¶
Constants ¶
const ( CREATE = iota UPDATE )
Variables ¶
var ErrProfileNotFound = errors.New("Profile Not Found")
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct { *controller.Controller // contains filtered or unexported fields }
Controller provides the end point for the routers.
func NewController ¶
func NewController(jwt *auth.JWT, service Service) *Controller
NewController creates a new instance of Controller.
func (*Controller) Create ¶
func (c *Controller) Create(w http.ResponseWriter, r *http.Request)
Create a new profile. Create end point for route .../profile [POST method].
func (*Controller) Get ¶
func (c *Controller) Get(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Get a profile by ID. Get end point for route .../profile [GET method]
func (*Controller) Update ¶
func (c *Controller) Update(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Update updates profile data. Update end point for route .../profile [PUT method].
type DAO ¶
type DAO interface { Get(ID string) (Profile, error) Create(profile Profile) error Update(profile Profile) error }
DAO interface for profile data source.
func NewPostgresDAO ¶
NewPostgresDAO creates a new instance of DAO.
type Profile ¶
type Profile struct { ID string `json:"id"` Name string `json:"name"` Lastname string `json:"lastname"` Password string `json:"password,omitempty"` }
Profile data model
func (Profile) CreatedEvent ¶
func (c Profile) CreatedEvent() integration.EventMessage
CreatedEvent returns message with profile creation event.
func (Profile) UpdatedEvent ¶
func (c Profile) UpdatedEvent() integration.EventMessage
UpdatedEvent returns message with profile update event.
type Repository ¶
type Repository interface { Get(ID string) (Profile, error) Create(profile Profile) error Update(profile Profile) error }
Repository interface for profile data source.
func NewRepository ¶
func NewRepository(dao DAO) Repository
NewRepository creates a new instance of Repository.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router for Profile end points.
func NewRoutes ¶
func NewRoutes(controller *Controller, auth *middleware.Auth) *Router
NewRoutes creates a router for Profile.
type Service ¶
type Service interface { Get(ID string) (Profile, error) Create(profile Profile) error Update(profile Profile) error }
Service provides business rules for the controller layer.
func NewService ¶
func NewService(repository Repository) Service
NewService creates a new instance of Service.