api

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
	Meta    *Meta       `json:"meta,omitempty"`
}

APIResponse represents a standard API response

type APIServer

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

APIServer provides REST endpoints for Termonaut

func NewAPIServer

func NewAPIServer(db *database.DB, port int) *APIServer

NewAPIServer creates a new API server

func (*APIServer) SetAuthenticator

func (s *APIServer) SetAuthenticator(auth Authenticator)

SetAuthenticator sets the authentication method

func (*APIServer) Start

func (s *APIServer) Start() error

Start starts the API server

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request) (*User, error)
}

Authenticator interface for API authentication

type Meta

type Meta struct {
	Total     int    `json:"total,omitempty"`
	Page      int    `json:"page,omitempty"`
	PerPage   int    `json:"per_page,omitempty"`
	HasMore   bool   `json:"has_more,omitempty"`
	Timestamp string `json:"timestamp"`
}

Meta represents response metadata

type User

type User struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Role     string `json:"role"`
}

User represents an authenticated user

Jump to

Keyboard shortcuts

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