meari

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package meari provides a simple webserver feature to enable interactive actions such as MTR looking glass.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultServer

type DefaultServer struct {
	*echo.Echo
	// contains filtered or unexported fields
}

DefaultServer is a "echo" based simple webserver that implements the Server interface.

func NewDefaultServer added in v0.3.2

func NewDefaultServer(opts *Options) *DefaultServer

NewDefaultServer initializes an instance of defaultServer, registers the "root" handler, and returns it as a Server. Currently, Server works as a singleton.

func (*DefaultServer) Address

func (s *DefaultServer) Address() string

Address implements the Server interface.

func (*DefaultServer) GET

func (s *DefaultServer) GET(path string, handler echo.HandlerFunc)

GET implements the Server interface.

func (*DefaultServer) Serve added in v0.4.0

func (s *DefaultServer) Serve() error

Serve implements the Server interface.

func (*DefaultServer) Shutdown

func (s *DefaultServer) Shutdown(c context.Context) error

Shutdown implements the Server interface.

type Options

type Options struct {
	Logger  common.Logger
	Address string
}

Options is a basic structure that contains all options for the Server implementation.

type Server

type Server interface {
	// Address returns the address on which the server is listening.
	Address() string
	// Serve starts the webserver and wait until the server stops.
	// It has the same behavior of `(http.Server).Serve()` and always returns
	// non-nil error. Expected error is `http.ErrServerClosed`.
	Serve() error
	// Shutdown stops the webserver gracefully.
	// It is equivalent to `(http.Server).Shutdown()`
	Shutdown(context context.Context) error
	// GET registers a new GET route for the given path with the given request handler.
	GET(path string, handler echo.HandlerFunc)
}

Server is an interface for the built-in webserver.

func NewServer added in v0.3.2

func NewServer(c common.Context, opts *common.Options) (Server, error)

NewServer initializes a new `defaultServer`, registers all available request handlers, then returns the Server instance.

Jump to

Keyboard shortcuts

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