webapp

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: AGPL-3.0 Imports: 59 Imported by: 0

Documentation

Overview

Package webapp provides the HTTP web application and API server for Omnom.

This package implements the web interface and REST API using the Gin web framework. It handles:

  • User authentication and session management
  • HTML page rendering with Go templates
  • RESTful API endpoints for bookmarks, feeds, and snapshots
  • Static file serving
  • OAuth authentication (GitHub, Google, OIDC)
  • ActivityPub federation endpoints
  • CSRF protection
  • Request localization
  • RSS/Atom feed generation

The web application provides both a browser-based UI and a programmatic API. Browser extensions and mobile apps can use the API with token-based authentication.

Key features:

  • Passwordless login via email tokens
  • OAuth provider integration
  • Real-time bookmark management
  • Content snapshot viewing with diff support
  • Feed aggregation and reading
  • Collection-based organization
  • Tag-based filtering
  • Full-text search

The Run function initializes middleware, routes, and starts the HTTP server:

webapp.Run(cfg)

API endpoints are documented and can be exported as Markdown using the generate-api-docs-md command.

Index

Constants

View Source
const (
	// GET is HTTP GET request type
	GET string = "GET"
	// POST is HTTP POST request type
	POST string = "POST"
	// PUT is HTTP PUT request type
	PUT string = "PUT"
	// PATCH is HTTP PATCH request type
	PATCH string = "PATCH"
	// HEAD is HTTP HEAD request type
	HEAD string = "HEAD"
)
View Source
const (
	// SID is the default session identifier name
	SID string = "sid"
)

Variables

View Source
var Endpoints []*Endpoint

Endpoints contains all registered API endpoints.

View Source
var URLFor func(string, ...string) string

URLFor generates URLs for named routes.

Functions

func CSRFMiddleware added in v0.2.0

func CSRFMiddleware() gin.HandlerFunc

CSRFMiddleware provides CSRF protection.

func ConfigMiddleware

func ConfigMiddleware(cfg *config.Config) gin.HandlerFunc

ConfigMiddleware injects configuration into the request context.

func ErrorLoggerMiddleware added in v0.2.0

func ErrorLoggerMiddleware() gin.HandlerFunc

ErrorLoggerMiddleware logs errors from requests.

func LocalizationMiddleware added in v0.5.0

func LocalizationMiddleware() gin.HandlerFunc

LocalizationMiddleware handles request localization.

func RSSEndpointWrapper added in v0.2.0

func RSSEndpointWrapper(f gin.HandlerFunc, rssVar string) gin.HandlerFunc

RSSEndpointWrapper wraps handlers to support RSS feed generation.

func Run

func Run(cfg *config.Config)

Run starts the web application server.

func SessionMiddleware

func SessionMiddleware(cfg *config.Config) gin.HandlerFunc

SessionMiddleware initializes session handling for requests.

Types

type Endpoint

type Endpoint struct {
	Name         string
	Path         string
	Method       string
	AuthRequired bool
	Handler      gin.HandlerFunc `json:"-"`
	Description  string
	Args         []*EndpointArg
	RSS          string
}

Endpoint represents an API endpoint definition.

type EndpointArg

type EndpointArg struct {
	Name               string
	Type               string
	Required           bool
	Description        string
	SkipAutoValidation bool `json:"-"`
}

EndpointArg represents an API endpoint argument.

type NotificationType added in v0.2.0

type NotificationType int

NotificationType represents the type of notification.

type ResourceMeta added in v0.2.0

type ResourceMeta struct {
	Filename  string `json:"filename"`
	Mimetype  string `json:"mimetype"`
	Extension string `json:"extension"`
}

ResourceMeta contains metadata about a webpage resource.

type ResourceMetas added in v0.2.0

type ResourceMetas []ResourceMeta

ResourceMetas is a collection of ResourceMeta objects.

Jump to

Keyboard shortcuts

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