api

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler processes HTTP API requests for tag management operations. It provides REST endpoints for adding, deleting, and retrieving tags.

func NewHandler

func NewHandler(tagManagerChan chan tag.Manager) *Handler

NewHandler creates a new API handler with the specified tag management channel.

Parameters:

  • tagManagerChan: Channel for sending tag management commands

func (*Handler) DeleteTag

func (h *Handler) DeleteTag(c *gin.Context)

DeleteTag handles HTTP DELETE requests to remove tags. It expects a JSON array of TagRecord objects in the request body. Returns 200 OK on success, 400 Bad Request for invalid JSON or validation errors, 404 Not Found if one or more tags do not exist, or 500 Internal Server Error for unexpected errors.

func (*Handler) GetTags

func (h *Handler) GetTags(c *gin.Context)

GetTags handles HTTP GET requests to retrieve all tags. Returns 200 OK with a JSON array of all currently stored tags.

func (*Handler) PostTag

func (h *Handler) PostTag(c *gin.Context)

PostTag handles HTTP POST requests to add new tags. It expects a JSON array of TagRecord objects in the request body. Returns 201 Created on success, 400 Bad Request for invalid JSON or validation errors, or 409 Conflict if one or more tags already exist.

type Server

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

Server provides an HTTP API server for tag management operations. It exposes REST endpoints for adding, deleting, and retrieving tags.

func NewServer

func NewServer(port int, tagManagerChan chan tag.Manager) *Server

NewServer creates and initializes a new API server.

Parameters:

  • port: Port number to listen on
  • tagManagerChan: Channel for tag management operations

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP API server and begins listening for requests. It registers routes for POST /api/v1/tags, DELETE /api/v1/tags, and GET /api/v1/tags. The server runs until an error occurs or it is stopped.

Returns an error if the server cannot start or encounters a fatal error.

Jump to

Keyboard shortcuts

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