api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, message string)

BadRequest writes a 400 error with the given message.

func Cors

func Cors(next http.Handler) http.Handler

Cors wraps a handler with CORS headers for local development.

func Error

func Error(w http.ResponseWriter, err error)

Error writes an error response, mapping domain errors to HTTP status codes.

func JSON

func JSON(w http.ResponseWriter, status int, data any)

JSON writes a JSON response with the given status code.

func Logging

func Logging(next http.Handler) http.Handler

Logging wraps a handler with request logging.

func NotFound added in v0.2.0

func NotFound(w http.ResponseWriter, resourceType, identifier string)

NotFound writes a 404 error for a missing resource.

Types

type CardResponse added in v0.3.0

type CardResponse struct {
	ID              string          `json:"id"`
	Alias           string          `json:"alias"`
	AliasExplicit   bool            `json:"alias_explicit"`
	Title           string          `json:"title"`
	Description     string          `json:"description,omitempty"`
	Column          string          `json:"column"`
	Parent          string          `json:"parent,omitempty"`
	Creator         string          `json:"creator"`
	CreatedAtMillis int64           `json:"created_at_millis"`
	UpdatedAtMillis int64           `json:"updated_at_millis"`
	Comments        []model.Comment `json:"comments,omitempty"`
	CustomFields    map[string]any  `json:"-"` // Flattened into top level by MarshalJSON
}

CardResponse wraps a Card for JSON API responses, including the Column field which is computed (from board config) and not persisted to card files. Custom fields are flattened into the top level to match the card JSON storage format.

func (CardResponse) MarshalJSON added in v0.3.0

func (c CardResponse) MarshalJSON() ([]byte, error)

MarshalJSON flattens custom fields into the top level of the JSON output.

type CreateCardRequest

type CreateCardRequest struct {
	Title        string            `json:"title"`
	Description  string            `json:"description,omitempty"`
	Column       string            `json:"column,omitempty"`
	Parent       string            `json:"parent,omitempty"`
	CustomFields map[string]string `json:"custom_fields,omitempty"`
}

CreateCardRequest is the JSON body for creating a card.

type Handler

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

Handler contains all HTTP handlers for the API.

func NewHandler

func NewHandler(
	cardService *service.CardService,
	boardService *service.BoardService,
	cardStore store.CardStore,
	boardStore store.BoardStore,
	creator string,
) *Handler

NewHandler creates a new handler with the given dependencies.

func (*Handler) CreateCard

func (h *Handler) CreateCard(w http.ResponseWriter, r *http.Request)

CreateCard creates a new card.

func (*Handler) DeleteCard

func (h *Handler) DeleteCard(w http.ResponseWriter, r *http.Request)

DeleteCard deletes a card.

func (*Handler) GetBoard

func (h *Handler) GetBoard(w http.ResponseWriter, r *http.Request)

GetBoard returns a board's configuration.

func (*Handler) GetCard

func (h *Handler) GetCard(w http.ResponseWriter, r *http.Request)

GetCard returns a single card by ID.

func (*Handler) ListBoards

func (h *Handler) ListBoards(w http.ResponseWriter, r *http.Request)

ListBoards returns all board names.

func (*Handler) ListCards

func (h *Handler) ListCards(w http.ResponseWriter, r *http.Request)

ListCards returns all cards for a board, optionally filtered by column.

func (*Handler) MoveCard

func (h *Handler) MoveCard(w http.ResponseWriter, r *http.Request)

MoveCard moves a card to a different column.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes sets up all API routes on the given mux.

func (*Handler) StaticHandler

func (h *Handler) StaticHandler() http.Handler

StaticHandler returns a handler that serves the embedded frontend files.

func (*Handler) UpdateCard

func (h *Handler) UpdateCard(w http.ResponseWriter, r *http.Request)

UpdateCard updates an existing card.

type MoveCardRequest

type MoveCardRequest struct {
	Column   string `json:"column"`
	Position *int   `json:"position,omitempty"` // Optional: position in target column (-1 or omit for end)
}

MoveCardRequest is the JSON body for moving a card.

type Server

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

Server wraps the HTTP server for the web frontend.

func NewServer

func NewServer(handler *Handler, port int) *Server

NewServer creates a new server with the given handler and port.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the address the server is listening on.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server.

func (*Server) Start

func (s *Server) Start() error

Start begins listening for HTTP requests. Blocks until shutdown.

type UpdateCardRequest

type UpdateCardRequest struct {
	Title        *string           `json:"title,omitempty"`
	Description  *string           `json:"description,omitempty"`
	Column       *string           `json:"column,omitempty"`
	CustomFields map[string]string `json:"custom_fields,omitempty"`
}

UpdateCardRequest is the JSON body for updating a card.

Jump to

Keyboard shortcuts

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