login

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: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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) Login

func (c *Controller) Login(w http.ResponseWriter, r *http.Request)

Login returns a token if ID and password are valid. Login end point for route .../login [POST method]

func (*Controller) Update

func (c *Controller) Update(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Update updates password in data base. Update end point for route .../login [PUT method]

type DAO

type DAO interface {
	Login(login Login) (bool, error)
	Update(login Login) error
}

DAO interface for login data source.

func NewPostgresDAO

func NewPostgresDAO(db database.Database) DAO

NewPostgresDAO creates a new instance of DAO.

type Login

type Login struct {
	ID       string `json:"id"`
	Password string `json:"password"`
}

Login data model.

func (Login) Validate

func (l Login) Validate() error

Validate model login.

type Repository

type Repository interface {
	Login(login Login) (bool, error)
	Update(login Login) error
}

Repository interface for login 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 Login end points.

func NewRoutes

func NewRoutes(controller *Controller, auth *middleware.Auth) *Router

NewRoutes creates a router for Login.

func (*Router) Route

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

Route sets the end points for the Login.

type Service

type Service interface {
	Login(login Login) (*TokenAuth, error)
	Update(login Login) error
}

Service provides business rules for the controller layer.

func NewService

func NewService(repository Repository, jwt *auth.JWT) Service

NewService creates a new instance of Service.

type TokenAuth

type TokenAuth struct {
	Token string `json:"token"`
}

TokenAuth JWT token.

Jump to

Keyboard shortcuts

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