webserver

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: Apache-2.0 Imports: 20 Imported by: 1

README

go-webserver

Go Report Card Documentation license GitHub version GitHub issues

This is the basic structure I use when using Echo for creating a webserver.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	XMLName xml.Name `json:"-"`
	Error   string   `json:"error" xml:"message"`
}

ErrorResponse defines a generic error response for a web request

type Module

type Module interface {
	Register(router *echo.Echo) // The function which registers the endpoints on the router
	Start()                     // Executed when the server starts
	Stop()                      // Executed when the server stops
}

Module defines a server module

type Server

type Server struct {
	DefaultPort         string
	PrintRoutes         bool
	UseJobQueue         bool
	JobQueuePoolSize    int
	JobQueueConcurrency int
	// contains filtered or unexported fields
}

Server is an abstraction of a webserver

func New

func New() *Server

New returns a new Server instacce

func (*Server) Register

func (server *Server) Register(modules ...Module)

Register registers the modules on the main router

func (*Server) Start

func (server *Server) Start() error

Start starts the webserver on the indicated port

func (*Server) StartWithListener added in v1.0.4

func (server *Server) StartWithListener(listener net.Listener) error

StartWithListener starts the webserver using the given listener

func (*Server) Stop

func (server *Server) Stop()

Stop stops the server and performs the shutdown action for each module

Directories

Path Synopsis
cmd
jobrunner
A job runner for executing scheduled or ad-hoc tasks asynchronously from HTTP requests.
A job runner for executing scheduled or ad-hoc tasks asynchronously from HTTP requests.

Jump to

Keyboard shortcuts

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