server

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bietervertrag added in v0.3.0

func Bietervertrag(domain string, bieterID string, headerImage string, data pdfData) (*bytes.Buffer, error)

Bietervertrag creates the bietervertrag pdf for a bieter

func Run

func Run(ctx context.Context, configFile, dbFile string, defaultFiles DefaultFiles) error

Run starts the server until the context is canceled.

Types

type Config

type Config struct {
	AdminPW    string `toml:"admin_password"`
	ListenAddr string `toml:"listen_addr"`
	Domain     string `toml:"domain"`
}

Config does what it is named.

func DefaultConfig added in v0.1.1

func DefaultConfig() Config

DefaultConfig returns a config object with default values.

func LoadConfig

func LoadConfig(file string) (Config, error)

LoadConfig loads the config from a toml file.

type Database

type Database struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Database holds the data in memory and saves them to disk.

func NewDB

func NewDB(file string) (*Database, error)

NewDB load the db from file.

func (*Database) Bieter added in v0.1.1

func (db *Database) Bieter(id string) (json.RawMessage, bool)

Bieter returns the data for a bieterID.

func (*Database) BieterList added in v0.1.1

func (db *Database) BieterList() map[string]json.RawMessage

BieterList return all bieters.

func (*Database) ClearOffer added in v0.2.0

func (db *Database) ClearOffer(asAdmin bool) error

ClearOffer creates an event to remove all offers

func (*Database) DeleteBieter added in v0.1.1

func (db *Database) DeleteBieter(id string, asAdmin bool) error

DeleteBieter removes a bieter.

func (*Database) NewBieter added in v0.1.1

func (db *Database) NewBieter(payload json.RawMessage, asAdmin bool) (string, error)

NewBieter creates a new bieter and returns its id.

func (*Database) Offer added in v0.1.1

func (db *Database) Offer(id string) int

Offer returns the offer form a bieter.

func (*Database) SetState added in v0.1.1

func (db *Database) SetState(r io.Reader) error

SetState updates the db state.

func (*Database) State added in v0.1.1

func (db *Database) State() ServiceState

State returns the current state.

func (*Database) UpdateBieter added in v0.1.1

func (db *Database) UpdateBieter(id string, r io.Reader, asAdmin bool) (json.RawMessage, error)

UpdateBieter updates an existing bieter. The new payload is read from r and is returned (on success).

func (*Database) UpdateOffer added in v0.1.1

func (db *Database) UpdateOffer(id string, r io.Reader, asAdmin bool) error

UpdateOffer sets the offer of a bieter.

The offer is in cent. So 100 € would be 10_000

type DefaultFiles

type DefaultFiles struct {
	Index  []byte
	Elm    []byte
	Static fs.FS
}

DefaultFiles that are used, when the folders do not exist in the file system.

type Event

type Event interface {
	Name() string
	// contains filtered or unexported methods
}

Event is one change of the database.

type MultiFS

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

MultiFS implements fs.FS but uses many sources.

func (MultiFS) Open

func (fs MultiFS) Open(name string) (fs.File, error)

Open opens the file from the first source that contains it.

type ServiceState added in v0.1.1

type ServiceState int

ServiceState is the state of the service.

func (ServiceState) String added in v0.1.1

func (s ServiceState) String() string

type ViewBieter added in v0.1.1

type ViewBieter struct {
	ID      string          `json:"id"`
	Payload json.RawMessage `json:"payload"`
	Offer   int             `json:"offer"`
}

ViewBieter is the bieter data returned to the client

Jump to

Keyboard shortcuts

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