server

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MainService

func MainService(confPath string) error

func ValidateSecurityForListenAddr added in v0.2.0

func ValidateSecurityForListenAddr(conf *SecurityConf, listenAddr string) error

Types

type App

type App struct {
	logutil.Logger
	// contains filtered or unexported fields
}

func NewApp

func NewApp(conf *AppConf) (*App, error)

func (*App) Close

func (app *App) Close() error

func (*App) HandleAPIClearReadHistory

func (app *App) HandleAPIClearReadHistory(w http.ResponseWriter, r *http.Request)

DELETE /api/read_history

func (*App) HandleAPICreateBook added in v0.5.0

func (app *App) HandleAPICreateBook(w http.ResponseWriter, r *http.Request)

POST /api/books

func (*App) HandleAPICreateBookSource added in v0.5.0

func (app *App) HandleAPICreateBookSource(w http.ResponseWriter, r *http.Request)

POST /api/books/{book_id}/sources

func (*App) HandleAPICreateLayer

func (app *App) HandleAPICreateLayer(w http.ResponseWriter, r *http.Request)

POST /api/layers/{layer_path}

func (*App) HandleAPIDeleteBook

func (app *App) HandleAPIDeleteBook(w http.ResponseWriter, r *http.Request)

DELETE /api/books/{book_id}

func (*App) HandleAPIDeleteBookCover

func (app *App) HandleAPIDeleteBookCover(w http.ResponseWriter, r *http.Request)

DELETE /api/books/{book_id}/cover

func (*App) HandleAPIDeleteBookSource added in v0.5.0

func (app *App) HandleAPIDeleteBookSource(w http.ResponseWriter, r *http.Request)

DELETE /api/books/{book_id}/sources/{source_id}

func (*App) HandleAPIDeleteLayer

func (app *App) HandleAPIDeleteLayer(w http.ResponseWriter, r *http.Request)

DELETE /api/layers/{layer_path}

func (*App) HandleAPIDeleteTrashedBook added in v0.5.0

func (app *App) HandleAPIDeleteTrashedBook(w http.ResponseWriter, r *http.Request)

DELETE /api/trash/books/{book_id}

func (*App) HandleAPIFindDuplicateBooks

func (app *App) HandleAPIFindDuplicateBooks(w http.ResponseWriter, r *http.Request)

GET /api/books/duplicate

func (*App) HandleAPIGetBook

func (app *App) HandleAPIGetBook(w http.ResponseWriter, r *http.Request)

GET /api/books/{book_id}

func (*App) HandleAPIGetBookContent

func (app *App) HandleAPIGetBookContent(w http.ResponseWriter, r *http.Request)

GET /api/books/{book_id}/content

func (*App) HandleAPIGetBookCover

func (app *App) HandleAPIGetBookCover(w http.ResponseWriter, r *http.Request)

GET /api/books/{book_id}/cover

func (*App) HandleAPIGetBookSource added in v0.3.0

func (app *App) HandleAPIGetBookSource(w http.ResponseWriter, r *http.Request)

GET /api/books/{book_id}/sources/{source_id}

func (*App) HandleAPIGetBookSourceContent added in v0.3.0

func (app *App) HandleAPIGetBookSourceContent(w http.ResponseWriter, r *http.Request)

GET /api/books/{book_id}/sources/{source_id}/content

func (*App) HandleAPIGetBookSources added in v0.3.0

func (app *App) HandleAPIGetBookSources(w http.ResponseWriter, r *http.Request)

GET /api/books/{book_id}/sources

func (*App) HandleAPIGetBookSplitConfig

func (app *App) HandleAPIGetBookSplitConfig(w http.ResponseWriter, r *http.Request)

GET /api/books/{book_id}/split_config

func (*App) HandleAPIGetBooks

func (app *App) HandleAPIGetBooks(w http.ResponseWriter, r *http.Request)

GET /api/books

func (*App) HandleAPIGetLayers

func (app *App) HandleAPIGetLayers(w http.ResponseWriter, r *http.Request)

GET /api/layers

func (*App) HandleAPIGetMarks

func (app *App) HandleAPIGetMarks(w http.ResponseWriter, r *http.Request)

GET /api/marks/{book_id}

func (*App) HandleAPIGetReadHistory

func (app *App) HandleAPIGetReadHistory(w http.ResponseWriter, r *http.Request)

GET /api/read_history

func (*App) HandleAPIGetTrashedBooks added in v0.5.0

func (app *App) HandleAPIGetTrashedBooks(w http.ResponseWriter, r *http.Request)

GET /api/trash/books

func (*App) HandleAPIImportBook

func (app *App) HandleAPIImportBook(w http.ResponseWriter, r *http.Request)

POST /api/books/import

func (*App) HandleAPIRestoreTrashedBook added in v0.5.0

func (app *App) HandleAPIRestoreTrashedBook(w http.ResponseWriter, r *http.Request)

POST /api/trash/books/{book_id}/restore

func (*App) HandleAPITrashBook added in v0.5.0

func (app *App) HandleAPITrashBook(w http.ResponseWriter, r *http.Request)

POST /api/books/{book_id}/trash

func (*App) HandleAPIUpdateBook

func (app *App) HandleAPIUpdateBook(w http.ResponseWriter, r *http.Request)

PATCH /api/books/{book_id}

func (*App) HandleAPIUpdateBookCover

func (app *App) HandleAPIUpdateBookCover(w http.ResponseWriter, r *http.Request)

PUT /api/books/{book_id}/cover

func (*App) HandleAPIUpdateBookSourceContent added in v0.3.0

func (app *App) HandleAPIUpdateBookSourceContent(w http.ResponseWriter, r *http.Request)

PATCH /api/books/{book_id}/sources/{source_id}/content

func (*App) HandleAPIUpdateBookSplitConfig

func (app *App) HandleAPIUpdateBookSplitConfig(w http.ResponseWriter, r *http.Request)

PATCH /api/books/{book_id}/split_config

func (*App) HandleAPIUpdateMarks

func (app *App) HandleAPIUpdateMarks(w http.ResponseWriter, r *http.Request)

POST /api/marks/{book_id}

func (*App) HandleAPIUpdateReadHistory

func (app *App) HandleAPIUpdateReadHistory(w http.ResponseWriter, r *http.Request)

POST /api/read_history?book_id={book_id}

func (*App) HandleSPAFallback

func (app *App) HandleSPAFallback(w http.ResponseWriter, r *http.Request)

Handle SPA fallback for all non-API GET requests

func (*App) Handler added in v0.2.0

func (app *App) Handler() http.Handler

func (*App) Health

func (app *App) Health(w http.ResponseWriter, r *http.Request)

func (*App) ImportFromLocalPath added in v0.5.0

func (app *App) ImportFromLocalPath(localPath string, layerParts shelf.Layers) (*shelf.Book, error)

ImportFromLocalPath imports a book from a local file path on the server. This is intended for desktop application use, where the client can specify a local file path and the server can access it directly.

func (*App) SecurityToken added in v0.2.0

func (app *App) SecurityToken() string

func (*App) SecurityTokenHeader added in v0.2.0

func (app *App) SecurityTokenHeader() string

func (*App) Serve

func (app *App) Serve(mux *http.ServeMux)

func (*App) Start

func (app *App) Start() error

type AppConf

type AppConf struct {
	Logger           logutil.LogConf  `yaml:"logger"`
	Shelf            *shelf.ShelfConf `yaml:"shelf"`
	StorePath        string           `yaml:"store_path"`
	CoverToJPG       bool             `yaml:"cover_to_jpg"`
	ReadHistoryLimit int              `yaml:"read_history_limit"`
	Security         *SecurityConf    `yaml:"security"`
}

type Book

type Book struct {
	Meta  *shelf.BookMeta `json:"meta"`
	Layer shelf.Layers    `json:"layer"`
}

type Security added in v0.2.0

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

func NewSecurity added in v0.2.0

func NewSecurity(conf *SecurityConf) (*Security, error)

func (*Security) IsEnabled added in v0.2.0

func (sec *Security) IsEnabled() bool

func (*Security) LogStartup added in v0.2.0

func (sec *Security) LogStartup(logger *logutil.Logger)

func (*Security) Middleware added in v0.2.0

func (sec *Security) Middleware(next http.Handler) http.Handler

func (*Security) Token added in v0.2.0

func (sec *Security) Token() string

func (*Security) TokenHeader added in v0.2.0

func (sec *Security) TokenHeader() string

type SecurityConf added in v0.2.0

type SecurityConf struct {
	Mode                        SecurityMode `yaml:"mode"`
	ProtectRead                 bool         `yaml:"protect_read"`
	TokenHeader                 string       `yaml:"token_header"`
	AllowMissingOriginWithToken *bool        `yaml:"allow_missing_origin_with_token"`
	AllowedOrigins              []string     `yaml:"allowed_origins"`
}

type SecurityMode added in v0.2.0

type SecurityMode string
const (
	SecurityModeUnset      SecurityMode = ""
	SecurityModeLocalToken SecurityMode = "local_token"
	SecurityModeNone       SecurityMode = "none"
	SecurityModePassword   SecurityMode = "password"
	SecurityModeExternal   SecurityMode = "external"
)

type SrvConf

type SrvConf struct {
	Logger     logutil.LogConf `yaml:"logger"`
	ServerConf *httputil.Conf  `yaml:"server_conf"`
	AppConf    *AppConf        `yaml:"app_conf"`
}

type TrashedBook added in v0.5.0

type TrashedBook struct {
	ID            string        `json:"id"`
	Title         string        `json:"title"`
	Authors       []string      `json:"authors,omitempty"`
	OriginalPath  string        `json:"original_path,omitempty"`
	OriginalLayer shelf.Layers  `json:"original_layer,omitempty"`
	DeletedAt     util.JSONTime `json:"deleted_at,omitzero"`
}

type UpdateBookRequest

type UpdateBookRequest struct {
	Title       *string        `json:"title"`
	Authors     *[]string      `json:"authors"`
	Tags        *[]string      `json:"tags"`
	Language    *string        `json:"language"`
	Comment     *string        `json:"comment"`
	PublishedAt *util.JSONTime `json:"published_at"`
	Layer       *shelf.Layers  `json:"layer"`
	Layers      *shelf.Layers  `json:"layers"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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