Documentation
¶
Index ¶
- Constants
- func FileServerFS(r chi.Router, path string, root fs.FS)
- func NewServer(todoStore TodoStore, options ...Option) (*server, error)
- type API
- type APIHandler
- type CreateTodoResponse
- type DeleteTodoResponse
- type GetTodoResponse
- type ListTodosResponse
- type Option
- type Page
- type PageHandler
- type RequestIDSetter
- type Todo
- type TodoStore
- type UpdateTodoResponse
- type ViewTodoResponse
Constants ¶
View Source
const ( TodoStatusUnknown = "UNKNOWN" TodoStatusNew = "NEW" TodoStatusDoing = "DOING" TodoStatusPending = "PENDING" TodoStatusDone = "DONE" )
View Source
const (
MsgOK = "ok"
)
Variables ¶
This section is empty.
Functions ¶
func FileServerFS ¶
FileServerFS conveniently sets up a http.FileServer handler to serve static files from a fs.FS.
Types ¶
type API ¶
type API struct { Status int Message string Data any Err error RequestID string Extra map[string]any }
API ...
func (*API) WithMessage ¶
func (*API) WithRequestID ¶
func (*API) WithStatus ¶
type APIHandler ¶
type APIHandler func(w http.ResponseWriter, r *http.Request) *API
type CreateTodoResponse ¶
type CreateTodoResponse struct {
ID int64 `json:"id"`
}
type DeleteTodoResponse ¶
type DeleteTodoResponse struct {
ID int64 `json:"id"`
}
type GetTodoResponse ¶
type GetTodoResponse struct {
Todo Todo `json:"todo"`
}
type ListTodosResponse ¶
type ListTodosResponse struct {
Todos []Todo `json:"todos"`
}
type PageHandler ¶
type PageHandler func(w http.ResponseWriter, r *http.Request) *Page
type RequestIDSetter ¶
type RequestIDSetter interface {
SetRequestID(id string)
}
type TodoStore ¶
type TodoStore interface { CreateTodo(ctx context.Context, params todostore.CreateTodoParams) (int64, error) UpdateTodo(ctx context.Context, id int64, params todostore.UpdateTodoParams) error FindTodos(ctx context.Context, params todostore.FindTodosParams) ([]todostore.Todo, error) DeleteTodo(ctx context.Context, id int64) error }
type UpdateTodoResponse ¶
type UpdateTodoResponse struct {
ID int64 `json:"id"`
}
type ViewTodoResponse ¶
Click to show internal directories.
Click to hide internal directories.