handlers

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnhancedReadinessHandler

func EnhancedReadinessHandler(sharedDir string) http.HandlerFunc

EnhancedReadinessHandler checks that the service can serve traffic: database is reachable and the shared directory is available.

GET /health/ready

func FormatFileSize

func FormatFileSize(bytes int64) string

FormatFileSize formats file size in human-readable format

func FormatModTime

func FormatModTime(modTime string) string

FormatModTime formats modification time

func HealthIndexHandler

func HealthIndexHandler(sharedDir string) http.HandlerFunc

HealthIndexHandler responds on the base /health path with an overview of all probes, so operators can hit a single URL.

GET /health

func IsFile

func IsFile(path string) bool

IsFile checks if the given path is a file

func LLMsTxtHandler added in v0.2.7

func LLMsTxtHandler(w http.ResponseWriter, r *http.Request)

LLMsTxtHandler serves the /llms.txt file for LLM discoverability.

func LivenessHandler

func LivenessHandler(w http.ResponseWriter, r *http.Request)

LivenessHandler returns 200 as long as the process is alive. This is the cheapest possible probe – no I/O.

GET /health/live

func LogsHandler

func LogsHandler() http.HandlerFunc

LogsHandler returns an HTTP handler that reads and serves structured JSON logs from the beamdrop log file.

Query parameters:

  • limit: max entries to return (default 200, max 5000)
  • offset: number of entries to skip from the end (for pagination)
  • level: filter by log level (debug, info, warn, error)
  • search: case-insensitive substring match on the message field

func MarkStartupReady

func MarkStartupReady()

MarkStartupReady should be called after the server has finished all initialisation steps (DB migration, orphan cleanup, etc.) and is ready to serve traffic for the first time.

func ResolvePath

func ResolvePath(sharedDir, reqPath string) (string, error)

ResolvePath safely resolves a relative path within the shared directory

func StartupHandler

func StartupHandler(w http.ResponseWriter, r *http.Request)

StartupHandler returns 200 once MarkStartupReady() has been called, 503 before that. K8s uses this to know when the container has finished initialising so it can switch to liveness/readiness probes.

GET /health/startup

func StaticHandler

func StaticHandler(w http.ResponseWriter, r *http.Request)

func StatsHandler

func StatsHandler(w http.ResponseWriter, r *http.Request)

Types

type AuthHandler

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

AuthHandler handles authentication endpoints

func NewAuthHandler

func NewAuthHandler(ps *auth.PasswordService) *AuthHandler

NewAuthHandler creates a new auth handler

func (*AuthHandler) Login

func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request)

Login handles the login endpoint

func (*AuthHandler) Logout

func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request)

Logout handles the logout endpoint

func (*AuthHandler) Status

func (h *AuthHandler) Status(w http.ResponseWriter, r *http.Request)

Status handles the auth status endpoint

type AuthStatusResponse

type AuthStatusResponse struct {
	AuthEnabled   bool `json:"authEnabled"`
	Authenticated bool `json:"authenticated"`
}

AuthStatusResponse represents the auth status response

type ComponentStatus

type ComponentStatus struct {
	Status  string `json:"status"`            // "ok" | "degraded" | "unavailable"
	Message string `json:"message,omitempty"` // human-readable detail
	Latency string `json:"latency,omitempty"` // e.g. "1.23ms"
}

ComponentStatus describes the status of a single subsystem.

type CreateShareableLinkRequest

type CreateShareableLinkRequest struct {
	Path      string `json:"path"`
	Password  string `json:"password,omitempty"`
	ExpiresIn *int64 `json:"expiresIn,omitempty"` // Duration in seconds
}

CreateShareableLinkRequest represents the request to create a shareable link

type CreateShareableLinkResponse

type CreateShareableLinkResponse struct {
	Token     string     `json:"token"`
	URL       string     `json:"url"`
	Path      string     `json:"path"`
	ExpiresAt *time.Time `json:"expiresAt,omitempty"`
	CreatedAt time.Time  `json:"createdAt"`
}

CreateShareableLinkResponse represents the response after creating a shareable link

type DownloadHandler added in v0.2.0

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

func NewDownloadHandler added in v0.2.0

func NewDownloadHandler(sharedDir string) *DownloadHandler

func (*DownloadHandler) ServeHTTP added in v0.2.0

func (h *DownloadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type File

type File struct {
	Name      string `json:"name"`
	Size      string `json:"size"`
	IsDir     bool   `json:"isDir"`
	ModTime   string `json:"modTime"`
	Path      string `json:"path"`
	IsStarred bool   `json:"isStarred"`
}

File represents a file or directory in the file system

type FileHandler

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

func NewFileHandler

func NewFileHandler(sharedDir string) *FileHandler

func (*FileHandler) Download

func (h *FileHandler) Download(w http.ResponseWriter, r *http.Request)

func (*FileHandler) ListFiles

func (h *FileHandler) ListFiles(w http.ResponseWriter, r *http.Request)

func (*FileHandler) Upload

func (h *FileHandler) Upload(w http.ResponseWriter, r *http.Request)

type FileOperationsHandler

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

func NewFileOperationsHandler

func NewFileOperationsHandler(sharedDir string) *FileOperationsHandler

func (*FileOperationsHandler) Copy

func (*FileOperationsHandler) Mkdir

func (*FileOperationsHandler) Move

func (*FileOperationsHandler) Rename

func (*FileOperationsHandler) Search

func (*FileOperationsHandler) Star

func (*FileOperationsHandler) Starred

func (*FileOperationsHandler) Trash

func (*FileOperationsHandler) Write

type HealthResponse

type HealthResponse struct {
	Status     string                     `json:"status"`     // "healthy" | "unhealthy"
	Service    string                     `json:"service"`    // always "beamdrop"
	Version    string                     `json:"version"`    // build version
	Timestamp  string                     `json:"timestamp"`  // RFC 3339
	Components map[string]ComponentStatus `json:"components"` // per-component checks
}

HealthResponse is the envelope returned by all health endpoints.

type LogEntry

type LogEntry struct {
	Time    string         `json:"time"`
	Level   string         `json:"level"`
	Msg     string         `json:"msg"`
	Source  map[string]any `json:"source,omitempty"`
	Attrs   map[string]any `json:"attrs,omitempty"` // extra fields
	RawJSON string         `json:"-"`
}

LogEntry represents a single structured JSON log line.

type LoginRequest

type LoginRequest struct {
	Password string `json:"password"`
}

LoginRequest represents the login request body

type LoginResponse

type LoginResponse struct {
	Success bool   `json:"success"`
	Token   string `json:"token,omitempty"`
	Message string `json:"message,omitempty"`
}

LoginResponse represents the login response

type LogsResponse

type LogsResponse struct {
	Logs     []map[string]any `json:"logs"`
	Total    int              `json:"total"`
	Returned int              `json:"returned"`
	HasMore  bool             `json:"hasMore"`
	LogPath  string           `json:"logPath"`
}

LogsResponse is the JSON envelope returned by the /logs endpoint.

type MCPHandler added in v0.2.7

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

MCPHandler handles MCP protocol requests at /mcp. Supports Streamable HTTP transport: POST for JSON-RPC requests.

func NewMCPHandler added in v0.2.7

func NewMCPHandler(sharedDir string) *MCPHandler

NewMCPHandler creates a new MCP HTTP handler.

func (*MCPHandler) ServeHTTP added in v0.2.7

func (h *MCPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles MCP requests.

type ShareableLinkHandler

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

func NewShareableLinkHandler

func NewShareableLinkHandler(sharedDir string) *ShareableLinkHandler

func (*ShareableLinkHandler) Access

Access handles GET requests to access a file/folder via shareable link (public API endpoint)

func (*ShareableLinkHandler) Create

Create handles POST requests to create a new shareable link

func (*ShareableLinkHandler) Delete

Delete handles DELETE requests to remove a shareable link

func (*ShareableLinkHandler) List

List handles GET requests to list all shareable links

type ShareableLinkInfo

type ShareableLinkInfo struct {
	ID          uint       `json:"id"`
	Path        string     `json:"path"`
	Token       string     `json:"token"`
	HasPassword bool       `json:"hasPassword"`
	ExpiresAt   *time.Time `json:"expiresAt,omitempty"`
	AccessCount int        `json:"accessCount"`
	CreatedAt   time.Time  `json:"createdAt"`
	IsDir       bool       `json:"isDir"`
}

ShareableLinkInfo represents link information without sensitive data

type ValidateLinkRequest

type ValidateLinkRequest struct {
	Password string `json:"password,omitempty"`
}

ValidateLinkRequest represents the request to validate a link with password

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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