account

package
v0.0.0-...-4cb2882 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRepo = errors.New("unable to handle repo request")

ErrRepo is returned when there is an error communicating with the database.

Functions

func NewHTTPServer

func NewHTTPServer(ctx context.Context, endpoints Endpoints) http.Handler

NewHTTPServer creates and returns the HTTP server.

Types

type CreateUserRequest

type CreateUserRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

CreateUserRequest holds the information for the create user request.

type CreateUserResponse

type CreateUserResponse struct {
	OK string `json:"ok"`
}

CreateUserResponse holds the information for the create user response.

type Endpoints

type Endpoints struct {
	CreateUser endpoint.Endpoint
	GetUser    endpoint.Endpoint
}

Endpoints defines the endpoints that will be exposed to the public.

func MakeEndpoints

func MakeEndpoints(s Service) Endpoints

MakeEndpoints creates and returns the Endpoints struct.

type GetUserRequest

type GetUserRequest struct {
	ID string `json:"id"`
}

GetUserRequest holds the information for the get user request.

type GetUserResponse

type GetUserResponse struct {
	Email string `json:"email"`
}

GetUserResponse holds the information for the get user response.

type Repository

type Repository interface {
	CreateUser(ctx context.Context, user User) error
	GetUser(ctx context.Context, id string) (string, error)
}

Repository defines the interface for database interaction.“

func NewRepo

func NewRepo(db *sql.DB, logger log.Logger) Repository

NewRepo creates and returns a new implementation of a Repository.

type Service

type Service interface {
	CreateUser(ctx context.Context, email string, password string) (string, error)
	GetUser(ctx context.Context, id string) (string, error)
}

Service defines the interface for the account service.

func NewService

func NewService(repo Repository, logger log.Logger) Service

NewService creates and returns a new implementation of Service.

type User

type User struct {
	ID       string `json:"id,omitempty"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

User holds the information for a user.

Jump to

Keyboard shortcuts

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