lib

package
v0.0.0-...-f8930f8 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBHost = "Host"

	DBUsername = "User"

	DBPass = "Pass"

	DBPort = "Port"

	Development = "Development"
)
View Source
const (
	Port = 8081
)

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware(nextHandler http.HandlerFunc) http.HandlerFunc

func GNUMiddleware

func GNUMiddleware(nextHandler http.HandlerFunc) http.HandlerFunc

GNUMiddleware adds the X-Clacks-Overhead header to keep names alive (https://wiki.lspace.org/GNU_Terry_Pratchett)

func GetLogger

func GetLogger(cfg *Config) *zap.Logger

func GetQueryId

func GetQueryId(r *http.Request, key string) (int, error)

func WriteError

func WriteError(log *zap.Logger, w http.ResponseWriter, statusCode int, err error, logMsg, errMsg string)

func WriteJson

func WriteJson(log *zap.Logger, w http.ResponseWriter, marshalled []byte)

Types

type ApiRouter

type ApiRouter interface {
	GetRoutes() []*Route
}

type Config

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

func NewConfig

func NewConfig(requiredConfigs ...string) (*Config, error)

func (*Config) Get

func (c *Config) Get(key string) (string, error)

func (*Config) Populate

func (c *Config) Populate(requiredConfigs []string) error

func (*Config) Set

func (c *Config) Set(key, value string)

type DBClient

type DBClient struct {
	Db *sqlx.DB
	// contains filtered or unexported fields
}

func NewDBClient

func NewDBClient(cfg *Config, log *zap.Logger) (*DBClient, error)

func (*DBClient) CheckConnection

func (d *DBClient) CheckConnection() error

type DBError

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

func NewDBError

func NewDBError(query string, innerErr error) *DBError

func (*DBError) Error

func (d *DBError) Error() string

type MiddlewareFunc

type MiddlewareFunc func(nextHandler http.HandlerFunc) http.HandlerFunc

type Route

type Route struct {
	Path       string
	Method     string
	Handler    http.HandlerFunc
	MiddleWare MiddlewareFunc
}

type Server

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

func NewWebServer

func NewWebServer(cfg *Config, log *zap.Logger, setupRoutes func(router *mux.Router)) *Server

func (*Server) Serve

func (s *Server) Serve() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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