controller

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Covers

func Covers(c *fiber.Ctx, homeDir, libraryPath string, metadataReaders map[string]metadata.Reader, coverMaxWidth int, embedded embed.FS) error

func DocReader

func DocReader(c *fiber.Ctx, libraryPath string) error

func Root

func Root(c *fiber.Ctx) error
func Search(c *fiber.Ctx, idx Reader, version string, sender Sender, wordsPerMinute float64) error

func Send

func Send(c *fiber.Ctx, libraryPath string, fileName string, address string, sender Sender) error

Types

type Auth

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

func NewAuth

func NewAuth(repository authRepository, sender recoveryEmail, cfg AuthConfig, printers map[string]*message.Printer) *Auth

func (*Auth) EditPassword

func (a *Auth) EditPassword(c *fiber.Ctx) error

func (*Auth) Login

func (a *Auth) Login(c *fiber.Ctx) error

func (*Auth) Recover

func (a *Auth) Recover(c *fiber.Ctx) error

func (*Auth) Request

func (a *Auth) Request(c *fiber.Ctx) error

func (*Auth) SignIn

func (a *Auth) SignIn(c *fiber.Ctx) error

Signs in a user and gives them a JWT.

func (*Auth) SignOut

func (a *Auth) SignOut(c *fiber.Ctx) error

Logs out user and removes their JWT.

func (*Auth) UpdatePassword

func (a *Auth) UpdatePassword(c *fiber.Ctx) error

type AuthConfig

type AuthConfig struct {
	Secret            []byte
	MinPasswordLength int
	Hostname          string
	Port              int
	SessionTimeout    time.Duration
}

type Page

type Page struct {
	Link      string
	IsCurrent bool
}

Page holds the URL of a results page, and if that page is the current one being shown

type PagesNavigator

type PagesNavigator struct {
	Pages        map[int]Page
	PreviousLink string
	NextLink     string
}

PagesNavigator contains all pages links, as well as links to the previous and next pages from the current one

type Reader

type Reader interface {
	Search(keywords string, page, resultsPerPage int, wordsPerMinute float64) (*Result, error)
	Count() (uint64, error)
	Close() error
}

Reader defines a set of reading operations over an index

type Result

type Result struct {
	Page       int
	TotalPages int
	Hits       []metadata.Metadata
	TotalHits  int
}

Result holds the result of a search request, as well as some related metadata

type Sender

type Sender interface {
	SendDocument(address string, libraryPath string, fileName string) error
	From() string
}

type Users

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

func NewUsers

func NewUsers(repository usersRepository, minPasswordLength int, wordsPerMinute float64) *Users

NewUsers returns a new instance of the users controller

func (*Users) Create

func (u *Users) Create(c *fiber.Ctx) error

Create gathers information coming from the new user form and creates a new user

func (*Users) Delete

func (u *Users) Delete(c *fiber.Ctx) error

Delete soft-removes a user from the database

func (*Users) Edit

func (u *Users) Edit(c *fiber.Ctx) error

Edit renders the edit user form

func (*Users) List

func (u *Users) List(c *fiber.Ctx) error

List list all users registered in the database

func (*Users) New

func (u *Users) New(c *fiber.Ctx) error

New renders the new user form

func (*Users) Update

func (u *Users) Update(c *fiber.Ctx) error

Update gathers information from the edit user form and updates user data

Jump to

Keyboard shortcuts

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