rest

package
v0.0.0-...-527e48b Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOpenAPI3

func NewOpenAPI3() openapi3.T

NewOpenAPI3 instantiates the OpenAPI specification for this service.

func RegisterOpenAPI

func RegisterOpenAPI(router *mux.Router)

Types

type CreateTasksRequest

type CreateTasksRequest struct {
	Description string   `json:"description"`
	Priority    Priority `json:"priority"`
	Dates       Dates    `json:"dates"`
}

CreateTasksRequest defines the request used for creating tasks.

type CreateTasksResponse

type CreateTasksResponse struct {
	Task Task `json:"task"`
}

CreateTasksResponse defines the response returned back after creating tasks.

type Dates

type Dates struct {
	Start time.Time `json:"start"`
	Due   time.Time `json:"due"`
}

Dates indicates a point in time where a task starts or completes, dates are not enforced on Tasks.

func NewDates

func NewDates(d internal.Dates) Dates

NewDates ...

func (Dates) Convert

func (d Dates) Convert() internal.Dates

Convert returns the domain type defining the internal representation.

type ErrorResponse

type ErrorResponse struct {
	Error       string            `json:"error"`
	Validations validation.Errors `json:"validations,omitempty"`
}

ErrorResponse represents a response containing an error message.

type Priority

type Priority string

Priority indicates how important a Task is.

func NewPriority

func NewPriority(p internal.Priority) Priority

NewPriority converts the received domain type to a rest type, when the argument is unknown "none" is used.

func (Priority) Convert

func (p Priority) Convert() internal.Priority

Convert returns the domain type defining the internal representation, when priority is unknown "none" is used.

func (Priority) MarshalJSON

func (p Priority) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Priority) UnmarshalJSON

func (p *Priority) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

func (Priority) Validate

func (p Priority) Validate() error

Validate ...

type ReadTasksResponse

type ReadTasksResponse struct {
	Task Task `json:"task"`
}

ReadTasksResponse defines the response returned back after searching one task.

type SearchTasksRequest

type SearchTasksRequest struct {
	Description *string   `json:"description"`
	Priority    *Priority `json:"priority"`
	IsDone      *bool     `json:"is_done"`
	From        int64     `json:"from"`
	Size        int64     `json:"size"`
}

SearchTasksRequest defines the request used for searching tasks. nolint: tagliatelle

type SearchTasksResponse

type SearchTasksResponse struct {
	Tasks []Task `json:"tasks"`
	Total int64  `json:"total"`
}

SearchTasksResponse defines the response returned back after searching for any task.

type Task

type Task struct {
	ID          string   `json:"id"`
	Description string   `json:"description"`
	Priority    Priority `json:"priority"`
	Dates       Dates    `json:"dates"`
	IsDone      bool     `json:"is_done"`
}

Task is an activity that needs to be completed within a period of time. nolint: tagliatelle

type TaskHandler

type TaskHandler struct {
	// contains filtered or unexported fields
}

TaskHandler ...

func NewTaskHandler

func NewTaskHandler(svc TaskService) *TaskHandler

NewTaskHandler ...

func (*TaskHandler) Register

func (t *TaskHandler) Register(r *mux.Router)

Register connects the handlers to the router.

type TaskService

type TaskService interface {
	By(ctx context.Context, args internal.SearchParams) (internal.SearchResults, error)
	Create(ctx context.Context, params internal.CreateParams) (internal.Task, error)
	Delete(ctx context.Context, id string) error
	Task(ctx context.Context, id string) (internal.Task, error)
	Update(ctx context.Context, id string, description string, priority internal.Priority, dates internal.Dates, isDone bool) error
}

TaskService ...

type UpdateTasksRequest

type UpdateTasksRequest struct {
	Description string   `json:"description"`
	IsDone      bool     `json:"is_done"`
	Priority    Priority `json:"priority"`
	Dates       Dates    `json:"dates"`
}

UpdateTasksRequest defines the request used for updating a task. nolint: tagliatelle

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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