Documentation ¶
Index ¶
- Variables
- func NewHTTPHandler(service Service, middlewares ...func(http.Handler) http.Handler) http.Handler
- func NewMongoClient(uri string, timeout int64) (*mongo.Client, error)
- func NewRepository(client *mongo.Client, dbname string) *repository
- func NewService(repository Repository) *service
- type ContextKey
- type Middleware
- type NewTask
- type NewTaskDocument
- type Repository
- type Server
- type Service
- type Task
- type TaskDocument
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrMissingField = errors.New("missing field is required")
View Source
var ErrTaskNotFound = errors.New("task not found")
Functions ¶
func NewHTTPHandler ¶
func NewRepository ¶
func NewService ¶
func NewService(repository Repository) *service
Types ¶
type Middleware ¶
type Middleware struct {
AuthEndpoint string
}
func (*Middleware) Authenticate ¶
func (m *Middleware) Authenticate(next http.Handler) http.Handler
type NewTask ¶
type NewTask struct { UserID string `json:"userId,omitempty"` Name string `json:"name"` Details string `json:"details,omitempty"` Priority string `json:"priority,omitempty"` Category string `json:"category,omitempty"` CreatedAt *time.Time `json:"createdAt,omitempty"` UpdatedAt *time.Time `json:"updatedAt,omitempty"` }
type NewTaskDocument ¶
type NewTaskDocument struct { UserID primitive.ObjectID `bson:"userId,omitempty"` Name string `bson:"name"` Details string `bson:"details,omitempty"` Priority string `bson:"priority,omitempty"` Category string `bson:"category,omitempty"` CreatedAt *time.Time `bson:"createdAt,omitempty"` UpdatedAt *time.Time `bson:"updatedAt,omitempty"` }
NewTaskDocument is an intermediary data type that is used by a repository layer that impements mongo to communicate with the mongodb driver API.
type Repository ¶
type Repository interface {
// contains filtered or unexported methods
}
type Task ¶
type Task struct { ID string `json:"taskId,omitempty"` UserID string `json:"userId,omitempty"` Name string `json:"name"` Details string `json:"details,omitempty"` Priority string `json:"priority,omitempty"` Category string `json:"category,omitempty"` CreatedAt *time.Time `json:"createdAt,omitempty"` UpdatedAt *time.Time `json:"updatedAt,omitempty"` }
type TaskDocument ¶
type TaskDocument struct { ID primitive.ObjectID `bson:"_id,omitempty"` UserID primitive.ObjectID `bson:"userId,omitempty"` Name string `bson:"name,omitempty"` Details string `bson:"details,omitempty"` Priority string `bson:"priority,omitempty"` Category string `bson:"category,omitempty"` CreatedAt *time.Time `bson:"createdAt,omitempty"` UpdatedAt *time.Time `bson:"updatedAt,omitempty"` }
TaskDocument is a data type used by a repository layer that implements mongo to communicate with the mongo API. The 'omitempty' tag is used to prevent an empty field value from whiping a document during an update.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.