websvc

package
v0.108.0-b.16 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package websvc contains the AdGuard Home web service.

TODO(a.garipov): Add tests.

Index

Constants

View Source
const (
	PathHealthCheck = "/health-check"

	PathV1SystemInfo = "/api/v1/system/info"
)

Path constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// TLS is the optional TLS configuration.  If TLS is not nil,
	// SecureAddresses must not be empty.
	TLS *tls.Config

	// Addresses are the addresses on which to serve the plain HTTP API.
	Addresses []netip.AddrPort

	// SecureAddresses are the addresses on which to serve the HTTPS API.  If
	// SecureAddresses is not empty, TLS must not be nil.
	SecureAddresses []netip.AddrPort

	// Start is the time of start of AdGuard Home.
	Start time.Time

	// Timeout is the timeout for all server operations.
	Timeout time.Duration
}

Config is the AdGuard Home web service configuration structure.

type RespGetV1SystemInfo

type RespGetV1SystemInfo struct {
	Arch       string   `json:"arch"`
	Channel    string   `json:"channel"`
	OS         string   `json:"os"`
	NewVersion string   `json:"new_version,omitempty"`
	Start      jsonTime `json:"start"`
	Version    string   `json:"version"`
}

RespGetV1SystemInfo describes the response of the GET /api/v1/system/info HTTP API.

type Service

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

Service is the AdGuard Home web service. A nil *Service is a valid agh.Service that does nothing.

func New

func New(c *Config) (svc *Service)

New returns a new properly initialized *Service. If c is nil, svc is a nil *Service that does nothing.

func (*Service) Addrs

func (svc *Service) Addrs() (addrs []string)

Addrs returns all addresses on which this server serves the HTTP API. Addrs must not be called until Start returns.

func (*Service) Shutdown

func (svc *Service) Shutdown(ctx context.Context) (err error)

Shutdown implements the agh.Service interface for *Service. svc may be nil.

func (*Service) Start

func (svc *Service) Start() (err error)

Start implements the agh.Service interface for *Service. svc may be nil. After Start exits, all HTTP servers have tried to start, possibly failing and writing error messages to the log.

Jump to

Keyboard shortcuts

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