Documentation ¶
Index ¶
- Variables
- func MakeAliveEndpoint(_ Service) endpoint.Endpoint
- func MakeDeleteTodoEndpoint(s Service) endpoint.Endpoint
- func MakeDeleteTodosEndpoint(s Service) endpoint.Endpoint
- func MakeGetTodoEndpoint(s Service) endpoint.Endpoint
- func MakeGetTodosEndpoint(s Service) endpoint.Endpoint
- func MakeHTTPHandler(s Service, logger log.Logger) http.Handler
- func MakePatchTodoEndpoint(s Service) endpoint.Endpoint
- func MakePostTodoEndpoint(s Service) endpoint.Endpoint
- func NewPostgresRepository(c *Config) (*postgresRepository, error)
- type Config
- type Endpoints
- type Middleware
- type Repository
- type Service
- type Todo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInconsistentIDs = errors.New("inconsistent IDs") ErrAlreadyExists = errors.New("already exists") ErrNotFound = errors.New("not found") )
View Source
var ( ErrBadRouting = errors.New("inconsistent mapping between route and handler (programmer error)") ErrNoInt = errors.New("input parameter isn't integer") )
Functions ¶
func MakeAliveEndpoint ¶
func MakeDeleteTodoEndpoint ¶
func MakeDeleteTodosEndpoint ¶
func MakeGetTodoEndpoint ¶
func MakeGetTodosEndpoint ¶
func MakePatchTodoEndpoint ¶
func MakePostTodoEndpoint ¶
func NewPostgresRepository ¶
Types ¶
type Config ¶
type Config struct { ServerPort string `envconfig:"port" default:"8080"` DatabaseHost string `default:"localhost"` DatabasePort string `default:"54321"` DatabaseUsername string `default:"todo"` DatabasePassword string `default:"todo"` DatabaseSchema string `default:"todo"` Url string `default:"http://localhost:8080"` }
func CreateConfig ¶
type Endpoints ¶
type Endpoints struct { AliveEndpoint endpoint.Endpoint GetTodosEndpoint endpoint.Endpoint GetTodoEndpoint endpoint.Endpoint PostTodoEndpoint endpoint.Endpoint DeleteTodosEndpoint endpoint.Endpoint DeleteTodoEndpoint endpoint.Endpoint PatchTodoEndpoint endpoint.Endpoint }
func MakeServerEndpoints ¶
type Middleware ¶
func LoggingMiddleware ¶
func LoggingMiddleware(logger log.Logger) Middleware
type Repository ¶
type Service ¶
type Service interface { GetTodos(ctx context.Context) ([]Todo, error) GetTodo(ctx context.Context, id int) (Todo, error) InsertTodo(ctx context.Context, t Todo) (Todo, error) DeleteTodos(ctx context.Context) error DeleteTodo(ctx context.Context, id int) error UpdateTodo(ctx context.Context, id int, t Todo) (Todo, error) Clear() error }
Service is a simple CRUD interface for user profiles.
func NewService ¶
func NewService(repository Repository, cfg *Config) Service
Click to show internal directories.
Click to hide internal directories.