server

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: BSD-3-Clause Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GzipMiddleware added in v0.3.0

func GzipMiddleware(next http.Handler) http.Handler

GzipMiddleware wraps an http.Handler to provide gzip compression

func HTTPRateLimitMiddleware added in v0.6.2

func HTTPRateLimitMiddleware(limiter *RateLimiter, next http.Handler) http.Handler

Creates an HTTP middleware that enforces rate limits per IP

func RateLimitMiddleware added in v0.2.0

func RateLimitMiddleware(limiter *RateLimiter) wish.Middleware

Creates a Wish middleware that enforces rate limits

Types

type APIConfig added in v0.6.0

type APIConfig struct {
	Title        string         `json:"title"`
	Description  string         `json:"description"`
	Author       string         `json:"author"`
	Themes       []APIThemeInfo `json:"themes"`
	DefaultTheme string         `json:"default_theme"`
	ASCIIHeader  string         `json:"ascii_header,omitempty"`
}

APIConfig exposes blog configuration to the WASM app

type APIPost added in v0.6.0

type APIPost struct {
	Slug         string   `json:"slug"`
	Title        string   `json:"title"`
	Description  string   `json:"description,omitempty"`
	Author       string   `json:"author,omitempty"`
	Tags         []string `json:"tags"`
	PublishedAt  string   `json:"published_at,omitempty"`
	ReadingTime  int      `json:"reading_time"`
	CanonicalURL string   `json:"canonical_url,omitempty"`
}

APIPost is a post summary for list endpoints

type APIPostDetail added in v0.6.0

type APIPostDetail struct {
	Slug         string   `json:"slug"`
	Title        string   `json:"title"`
	Description  string   `json:"description,omitempty"`
	Author       string   `json:"author,omitempty"`
	Content      string   `json:"content"`
	Tags         []string `json:"tags"`
	PublishedAt  string   `json:"published_at,omitempty"`
	ReadingTime  int      `json:"reading_time"`
	CanonicalURL string   `json:"canonical_url,omitempty"`
}

APIPostDetail is a full post with markdown content

type APIPostList added in v0.6.0

type APIPostList struct {
	Posts      []APIPost `json:"posts"`
	Total      int       `json:"total"`
	Page       int       `json:"page"`
	PerPage    int       `json:"per_page"`
	TotalPages int       `json:"total_pages"`
}

APIPostList is a paginated list of posts

type APISearchResult added in v0.6.0

type APISearchResult struct {
	Query   string    `json:"query"`
	Results []APIPost `json:"results"`
	Total   int       `json:"total"`
}

APISearchResult wraps search results

type APITag added in v0.6.0

type APITag struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

APITag represents a tag with its post count

type APIThemeColors added in v0.6.0

type APIThemeColors struct {
	Primary    string `json:"primary"`
	Secondary  string `json:"secondary"`
	Background string `json:"background"`
	Text       string `json:"text"`
	Muted      string `json:"muted"`
	Accent     string `json:"accent"`
	Error      string `json:"error"`
	Success    string `json:"success"`
	Warning    string `json:"warning"`
	Border     string `json:"border"`
}

APIThemeColors holds all theme color values

type APIThemeInfo added in v0.6.0

type APIThemeInfo struct {
	Key         string         `json:"key"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Colors      APIThemeColors `json:"colors"`
}

APIThemeInfo describes a theme for the client

type CommandHandler added in v0.3.0

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

CommandHandler handles non-interactive SSH commands

func NewCommandHandler added in v0.3.0

func NewCommandHandler(repo *storage.PostRepository, loader *blog.ContentLoader, feed *blog.FeedGenerator) *CommandHandler

NewCommandHandler creates a new command handler

func (*CommandHandler) HandleCommand added in v0.3.0

func (h *CommandHandler) HandleCommand(w io.Writer, args []string) (bool, error)

HandleCommand processes a non-interactive SSH command Returns true if the command was handled, false if it should fall through to TUI

type HTTPServer

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

Handles HTTP requests and serves the WASM web app

func NewHTTPServer

func NewHTTPServer(
	host string,
	port int,
	repo *storage.PostRepository,
	viewRepo *storage.ViewRepository,
	loader *blog.ContentLoader,
	feed *blog.FeedGenerator,
	blogTitle string,
	blogDescription string,
	blogAuthor string,
	asciiHeader string,
	t *theme.Theme,
	themeKey string,
	trustProxy bool,
	faviconCfg app.FaviconConfig,
) (*HTTPServer, error)

Creates a new HTTP server

func (*HTTPServer) ListenAndServeWithSignal

func (s *HTTPServer) ListenAndServeWithSignal() error

Starts the server and handles shutdown signals

func (*HTTPServer) Shutdown

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

Gracefully shuts down the HTTP server

func (*HTTPServer) Start

func (s *HTTPServer) Start() error

Starts the HTTP server

type RateLimiter added in v0.2.0

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

Tracks connection attempts per IP using a sliding window

func NewRateLimiter added in v0.2.0

func NewRateLimiter(limit int, window time.Duration) *RateLimiter

Creates a rate limiter with the given limit and time window

func (*RateLimiter) Allow added in v0.2.0

func (rl *RateLimiter) Allow(ip string) (allowed bool, count int)

Checks if a connection from the given IP should be allowed. Returns whether the request is allowed and the current request count for the IP.

func (*RateLimiter) Stop added in v0.2.0

func (rl *RateLimiter) Stop()

Stops the cleanup goroutine. Call this when shutting down. Safe to call multiple times.

type SSHConfig added in v0.2.0

type SSHConfig struct {
	RateLimitCount    int
	RateLimitWindow   time.Duration
	ExitMessage       string
	FeedGenerator     *blog.FeedGenerator // For RSS command support
	AdminFingerprints []string            // SSH fingerprints with admin access
}

SSHConfig holds SSH server-specific configuration

type SSHServer

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

SSHServer wraps the Wish SSH server

func NewSSHServer

func NewSSHServer(host string, port int, hostKeyPath string, repo *storage.PostRepository, prefRepo *storage.PreferenceRepository, viewRepo *storage.ViewRepository, loader *blog.ContentLoader, t *theme.Theme, tuiCfg tui.Config, sshCfg SSHConfig) (*SSHServer, error)

NewSSHServer creates a new SSH server

func (*SSHServer) ListenAndServeWithSignal

func (s *SSHServer) ListenAndServeWithSignal() error

ListenAndServeWithSignal starts the server and handles shutdown signals

func (*SSHServer) Shutdown

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

Shutdown gracefully shuts down the SSH server

func (*SSHServer) Start

func (s *SSHServer) Start() error

Start starts the SSH server

type ThemeColors added in v0.3.0

type ThemeColors struct {
	Background string
	Foreground string
	Muted      string
	Accent     string
	Border     string
}

Holds CSS-friendly theme colors for templates

Jump to

Keyboard shortcuts

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