website

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package website contains the service delivering the website

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerAlreadyStarted = errors.New("server was already started")
)

Functions

func ParseDailyStatsTemplate

func ParseDailyStatsTemplate() (*template.Template, error)

func ParseIndexTemplate

func ParseIndexTemplate() (*template.Template, error)

Types

type HTMLData

type HTMLData struct {
	Title     string
	TimeSpans []string
	TimeSpan  string
	View      string // overview or builder-profit

	Stats *Stats // stats for this view

	LastUpdateSlot    uint64
	LastUpdateTime    time.Time
	LastUpdateTimeStr string
}

type HTMLDataDailyStats

type HTMLDataDailyStats struct {
	Title string

	Day       string
	DayPrev   string
	DayNext   string
	TimeSince string
	TimeUntil string

	TopRelays            []*database.TopRelayEntry
	TopBuildersBySummary []*database.TopBuilderEntry
	BuilderProfits       []*database.BuilderProfitEntry
}

type HTTPErrorResp

type HTTPErrorResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Stats

type Stats struct {
	Since time.Time
	Until time.Time

	TimeStr string // i.e. 24h, 12h, 1h or 7d

	TopRelays          []*database.TopRelayEntry
	TopBuilders        []*database.TopBuilderEntry
	BuilderProfits     []*database.BuilderProfitEntry
	TopBuildersByRelay map[string][]*database.TopBuilderEntry
}

func NewStats added in v1.8.2

func NewStats() *Stats

type Webserver

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

func NewWebserver

func NewWebserver(opts *WebserverOpts) (*Webserver, error)

func (*Webserver) RespondError

func (srv *Webserver) RespondError(w http.ResponseWriter, code int, message string)

func (*Webserver) RespondErrorJSON added in v1.8.2

func (srv *Webserver) RespondErrorJSON(w http.ResponseWriter, code int, response any)

func (*Webserver) RespondOK

func (srv *Webserver) RespondOK(w http.ResponseWriter, response any)

func (*Webserver) StartServer

func (srv *Webserver) StartServer() (err error)

type WebserverOpts

type WebserverOpts struct {
	ListenAddress string
	DB            *database.DatabaseService
	Log           *logrus.Entry
	EnablePprof   bool
	Dev           bool // reloads template on every request
	Only24h       bool
}

Jump to

Keyboard shortcuts

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