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
- Variables
- func CSRFMiddleware() gin.HandlerFunc
- func ConfigMiddleware(cfg *config.Config) gin.HandlerFunc
- func ErrorLoggerMiddleware() gin.HandlerFunc
- func LocalizationMiddleware() gin.HandlerFunc
- func RSSEndpointWrapper(f gin.HandlerFunc, rssVar string) gin.HandlerFunc
- func Run(cfg *config.Config)
- func SessionMiddleware(cfg *config.Config) gin.HandlerFunc
- type Endpoint
- type EndpointArg
- type NotificationType
- type ResourceMeta
- type ResourceMetas
Constants ¶
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" )
const ( // SID is the default session identifier name SID string = "sid" )
Variables ¶
var Endpoints []*Endpoint
Endpoints contains all registered API endpoints.
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 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.