http

package
v0.0.0-...-83927be Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0, MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatValidationErrors

func FormatValidationErrors(err error) map[string]string

func GetHTTPStatusFromStoreError

func GetHTTPStatusFromStoreError(err error) (int, string)

Types

type Config

type Config struct {
	Addr            string
	Fqdn            string
	Port            int
	ListenPort      int
	ReadTimeout     int
	WriteTimeout    int
	ShutdownTimeout int

	Env string
	TLS bool
}

type HTTP

type HTTP struct {
	Addr            string `toml:"address"`
	Fqdn            string `toml:"fqdn"`
	Port            int    `toml:"port"`
	ListenPort      int    `toml:"listen-port"`
	ReadTimeout     int    `toml:"read-timeout"`
	WriteTimeout    int    `toml:"write-timeout"`
	ShutdownTimeout int    `toml:"shutdown-timeout"`
	TLS             bool   `toml:"tls"`
}

type Logger

type Logger struct {
	Level string `toml:"level"`
	Path  string `toml:"path"`
}

type Server

type Server struct {
	Validate *validator.Validate
	Log      *zap.Logger
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) *Server

func (*Server) Close

func (s *Server) Close() error

func (*Server) Decode

func (s *Server) Decode(dst any, src map[string][]string) error

func (*Server) DecodeJSON

func (s *Server) DecodeJSON(w http.ResponseWriter, r *http.Request, destination any) error

func (*Server) Host

func (s *Server) Host() string

func (*Server) JSON

func (s *Server) JSON(w http.ResponseWriter, r *http.Request, code int, value any)

func (*Server) LogDebug

func (s *Server) LogDebug(r *http.Request, err error)

func (*Server) LogError

func (s *Server) LogError(r *http.Request, err error)

func (*Server) LogWarn

func (s *Server) LogWarn(r *http.Request, err error)

func (*Server) RegisterMiddleWare

func (s *Server) RegisterMiddleWare(middlewares ...func(http.Handler) http.Handler)

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes(routes ...func(chi.Router))

func (*Server) Run

func (s *Server) Run() error

func (*Server) Schema

func (s *Server) Schema() string

func (*Server) URI

func (s *Server) URI() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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