httpserver

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ShutdownTimeOut = 10 * time.Second

ShutdownTimeOut is time to terminate queries when quit signal given.

Variables

View Source
var ErrLockedServer = errors.New("http server is locked")

ErrLockedServer returned on repeated call Close() the HTTP server.

Functions

This section is empty.

Types

type Binder

type Binder interface {
	Bind(c echo.Context, req interface{}) error
	BindAndValidate(c echo.Context, req interface{}) error
}

Binder represents Bind and BindAndValidate functions.

type Logger

type Logger interface {
	Infof(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Debug(args ...interface{})
	Error(args ...interface{})
	Writer() io.Writer
}

Logger describes Error and Info functions.

type Option

type Option func(server *Server)

Option infects params to Server.

func WithBinder

func WithBinder(binder Binder) Option

WithBinder injects Binder to Server.

func WithRecover

func WithRecover(rec bool) Option

func WithResponder

func WithResponder(responser Responder) Option

WithResponder injects Responder to Server.

type Param added in v0.2.2

type Param struct {
	Q       map[string]string `json:"q"`
	Sort    string            `json:"sort"`
	Offset  int               `json:"offset"`
	Limit   int               `json:"limit"`
	Mutator map[string]string `json:"mutator"`
}

func NewParam added in v0.2.2

func NewParam() *Param

type ReplacementFields added in v0.2.2

type ReplacementFields struct {
	// Fields that apply to the entire row.
	Keys []string

	// Fields related to the filter key `q`, which are then included in the SQL query.
	Query []string
}

ReplacementFields contains the fields that need to be replaced in the query string.

type Responder

type Responder interface {
	ServeResult(c echo.Context, i interface{}) error
	ServeError(c echo.Context, err error, logPrefix ...string) error
}

Responder represents ServeResult and ServeError functions.

type Server

type Server struct {
	Binder
	Responder
	Echo *echo.Echo
	// contains filtered or unexported fields
}

A Server defines parameters for running an HTTP server.

func NewServer

func NewServer(log Logger, errs chan error, options ...Option) *Server

NewServer allocates and returns a new Server.

func (*Server) Close

func (s *Server) Close() error

Close stops HTTP Server.

func (*Server) ParseQueryString added in v0.2.2

func (s *Server) ParseQueryString(c echo.Context, mapData *ReplacementFields) (*Param, error)

ParseQueryString parses the query string, does unescaping.

func (*Server) ReportError

func (s *Server) ReportError(err error)

ReportError publishes error to the errors channel. if you do not read errors from the errors channel then after the channel buffer overflows the application exits with a fatal level and the os.Exit(1) exit code.

func (*Server) Serve

func (s *Server) Serve(port string)

Serve initializes HTTP Server and runs it on received port.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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