restapi

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: LGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IP2LOCATION []byte

Functions

func WriteError

func WriteError(w http.ResponseWriter, status int)

func WriteJson

func WriteJson(w http.ResponseWriter, r *http.Request, data any)

Types

type ApiHandler

type ApiHandler struct {
	Method  string `json:"method"`
	Pattern string `json:"pattern"` // Context path pattern
	Desc    string `json:"desc"`    // What does the endpoint do?
	//	args    []string            // List of human-readable argument names
	Handler func(w http.ResponseWriter, r *http.Request) // First is input map, second is output
}

type Peer

type Peer struct {
	Address       string   `json:"address"`
	Key           string   `json:"key"`
	Port          uint64   `json:"port"`
	Priority      uint64   `json:"priority"`
	Coords        []uint64 `json:"coords"`
	Remote        string   `json:"remote"`
	Remote_ip     string   `json:"remote_ip"`
	Bytes_recvd   uint64   `json:"bytes_recvd"`
	Bytes_sent    uint64   `json:"bytes_sent"`
	Uptime        float64  `json:"uptime"`
	Multicast     bool     `json:"multicast"`
	Country_short string   `json:"country_short"`
	Country_long  string   `json:"country_long"`
}

type RestServer

type RestServer struct {
	RestServerCfg
	// contains filtered or unexported fields
}

func NewRestServer

func NewRestServer(cfg RestServerCfg) (*RestServer, error)

func (*RestServer) AddHandler

func (a *RestServer) AddHandler(handler ApiHandler) error

AddHandler is called for each admin function to add the handler and help documentation to the API.

func (*RestServer) Serve

func (a *RestServer) Serve() error

Start http server

func (*RestServer) Shutdown

func (a *RestServer) Shutdown() error

Shutdown http server

type RestServerCfg

type RestServerCfg struct {
	Core          *core.Core
	Multicast     *multicast.Multicast
	Log           core.Logger
	ListenAddress string
	WwwRoot       string
	ConfigFn      string

	Domain   string
	Features []string
	// contains filtered or unexported fields
}

type ServerEvent

type ServerEvent struct {
	Event string
	Data  []byte
}

Jump to

Keyboard shortcuts

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