profile

package
v0.0.0-...-94215c3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATE = iota
	UPDATE
)

Variables

View Source
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

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

func NewPostgresDAO(db database.Database) DAO

NewPostgresDAO creates a new instance of DAO.

type Operation

type Operation int

Operation type of operation such as CREATE and UPDATE.

func (Operation) String

func (o Operation) String() string

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.

func (Profile) Validate

func (p Profile) Validate(op Operation) error

Validate model Profile.

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.

func (*Router) Route

func (r *Router) Route(router *mux.Router)

Route sets the end points for the 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.

Jump to

Keyboard shortcuts

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