rest

package
v0.0.0-...-a2e4898 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TASK_PATH        = "/tasks"
	TASK_ID_PATH     = TASK_PATH + "/{id}"
	POMODORO_PATH    = "/pomodoros"
	POMODORO_ID_PATH = POMODORO_PATH + "/{id}"
	STATUS_PATH      = "/status"
)

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(r io.Reader, v interface{}) error

func New

func New(config *koanf.Koanf) (core.Server, error)

New will setup the API listener

func RenderErrInternal

func RenderErrInternal(w http.ResponseWriter, err error)

func RenderErrInternalWithID

func RenderErrInternalWithID(w http.ResponseWriter, err error) string

func RenderErrInvalidRequest

func RenderErrInvalidRequest(w http.ResponseWriter, err error)

func RenderErrNotFound

func RenderErrNotFound(w http.ResponseWriter)

func RenderErrResourceNotFound

func RenderErrResourceNotFound(w http.ResponseWriter, resource string)

func RenderErrUnauthorized

func RenderErrUnauthorized(w http.ResponseWriter)

func RenderJSON

func RenderJSON(w http.ResponseWriter, code int, v interface{})

RenderJSON writes an http response using the value passed in v as JSON. If it cannot convert the value to JSON, it returns an error

func RenderNoContent

func RenderNoContent(w http.ResponseWriter)

Types

type ErrResponse

type ErrResponse struct {
	Status  string `json:"status,omitempty"`
	Error   string `json:"error,omitempty"`
	ErrorID string `json:"error_id,omitempty"`
}

type RestServer

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

RestServer is the Rest web server

func (*RestServer) PomodoroDeleteByID

func (s *RestServer) PomodoroDeleteByID() http.HandlerFunc

PomodoroDeleteByID deletes a pomodoro

func (*RestServer) PomodoroGetByID

func (s *RestServer) PomodoroGetByID() http.HandlerFunc

PomodoroGetByID returns the pomodoro

func (*RestServer) PomodoroSave

func (s *RestServer) PomodoroSave() http.HandlerFunc

PomodoroSave saves a pomodoro

func (*RestServer) Router

func (s *RestServer) Router() chi.Router

Router returns the router

func (*RestServer) Setup

func (s *RestServer) Setup() error

Setup will setup the API listener

func (*RestServer) Start

func (s *RestServer) Start()

ListenAndServe will listen for requests

func (*RestServer) StatusGet

func (s *RestServer) StatusGet() http.HandlerFunc

GetStatus returns the server status

func (*RestServer) StatusSave

func (s *RestServer) StatusSave() http.HandlerFunc

StatusSave saves the server status

func (*RestServer) Stop

func (s *RestServer) Stop()

func (*RestServer) TaskDeleteByID

func (s *RestServer) TaskDeleteByID() http.HandlerFunc

TaskDeleteByID deletes a task

func (*RestServer) TaskGetByID

func (s *RestServer) TaskGetByID() http.HandlerFunc

TaskGetByID returns the task

func (*RestServer) TaskSave

func (s *RestServer) TaskSave() http.HandlerFunc

TaskSave saves a task

func (*RestServer) TasksFind

func (s *RestServer) TasksFind() http.HandlerFunc

TasksFind finds tasks

Jump to

Keyboard shortcuts

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