webserver

package
v4.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowIfNotLoggedIn

func AllowIfNotLoggedIn(jwtSecret []byte) func(fiber.Ctx) error

AllowIfNotLoggedIn only allows processing the request if there is no session

func AlwaysRequireAuthentication

func AlwaysRequireAuthentication(jwtSecret []byte, sender Sender, translator i18n.Translator, usersRepository *model.UserRepository) func(fiber.Ctx) error

AlwaysRequireAuthentication returns forbidden and renders the login page if the user trying to access has not logged in

func ConfigurableAuthentication

func ConfigurableAuthentication(jwtSecret []byte, sender Sender, translator i18n.Translator, requireAuth bool, usersRepository *model.UserRepository) func(fiber.Ctx) error

ConfigurableAuthentication allows to enable or disable authentication on routes which may or may not require it

func New

func New(cfg Config, controllers Controllers, sender Sender, idx ProgressInfo, usersRepository *model.UserRepository) *fiber.App

New builds a new Fiber application and set up the required routes

func OneTimeMessages added in v4.11.0

func OneTimeMessages() func(c fiber.Ctx) error

func RequireAdmin

func RequireAdmin(c fiber.Ctx) error

RequireAdmin returns HTTP forbidden if the user requesting access is not an admin

func SetActionPreferences added in v4.19.0

func SetActionPreferences(sender Sender) func(fiber.Ctx) error

SetActionPreferences computes and sets action-related preferences based on session and email configuration These values are used in templates to determine default actions, available options, and EPUB preferences

func SetAvailableLanguages added in v4.16.0

func SetAvailableLanguages(idx ProgressInfo) func(fiber.Ctx) error

SetAvailableLanguages retrieves available languages from the index and sets them as a local variable for use in templates

func SetConfigLocals added in v4.20.0

func SetConfigLocals(cfg Config) func(fiber.Ctx) error

SetConfigLocals sets config values in c.Locals() for template access

func SetEmailSendingConfigured added in v4.19.0

func SetEmailSendingConfigured(sender Sender) func(fiber.Ctx) error

SetEmailSendingConfigured sets EmailSendingConfigured in c.Locals() based on the sender type This should be run early in the middleware chain so it's available in all routes

func SetFQDN

func SetFQDN(cfg Config) func(fiber.Ctx) error

SetFQDN composes the Fully Qualified Domain Name of the host running the app and sets it as a local variable of the request. When behind a reverse proxy, X-Forwarded-Proto is used so that HTTPS is preserved and mixed-content is avoided (e.g. reader download URL).

func SetProgress

func SetProgress(progress ProgressInfo) func(fiber.Ctx) error

SetProgress retrieves indexing progress information from the index and sets it as a local variable of the request

Types

type Config

type Config struct {
	Version                    string
	SessionTimeout             time.Duration
	RecoveryTimeout            time.Duration
	InvitationTimeout          time.Duration
	MinPasswordLength          int
	WordsPerMinute             float64
	JwtSecret                  []byte
	Hostname                   string
	FQDN                       string
	Port                       int
	HomeDir                    string
	CacheDir                   string
	LibraryPath                string
	AuthorImageMaxWidth        int
	CoverMaxWidth              int
	RequireAuth                bool
	UploadDocumentMaxSize      int
	ClientStaticCacheTTL       int
	ClientDynamicImageCacheTTL int
	ServerStaticCacheTTL       int
	ServerDynamicImageCacheTTL int
	ShareCommentMaxSize        int
	ShareMaxRecipients         int
	IllustratedMinAmount       int
}

type Controllers

type Controllers struct {
	Auth       *auth.Controller
	Users      *user.Controller
	Completed  *completed.Controller
	Highlights *highlight.Controller
	Documents  *document.Controller
	Home       *home.Controller
	Authors    *author.Controller
	Series     *series.Controller
}

func SetupControllers

func SetupControllers(cfg Config, db *gorm.DB, metadataReaders map[string]metadata.Reader, idx *index.BleveIndexer, sender Sender, appFs afero.Fs, dataSource author.DataSource) Controllers

type ProgressInfo

type ProgressInfo interface {
	IndexingProgress() (index.Progress, error)
	Languages() ([]string, error)
}

type Sender

type Sender interface {
	Send(address, subject, body string) error
	SendBCC(addresses []string, subject, body string) error
	SendDocument(address, subject string, file []byte, fileName string) error
	From() string
}

Directories

Path Synopsis
controller

Jump to

Keyboard shortcuts

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