utils

package
v2.0.0-...-e48ae43 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiVersionKey contextKey = "apiVersion"
)

Variables

This section is empty.

Functions

func JSONError

func JSONError(w http.ResponseWriter, statusCode int, message string)

func JSONResponse

func JSONResponse(w http.ResponseWriter, statusCode int, data interface{})

func ParseJsonValidationError

func ParseJsonValidationError(err error) string

func VersionMiddleware

func VersionMiddleware(next http.Handler) http.Handler

VersionMiddleware is a custom middleware for extracting the API version from the header

Types

type EnvConfig

type EnvConfig struct {
	ServerPort int `env:"PORT,required"`

	DbHost     string `env:"DB_HOST,required"`
	DbUser     string `env:"DB_USER,required"`
	DbName     string `env:"DB_NAME,required"`
	DbPort     int    `env:"DB_PORT,required"`
	DbPassword string `env:"DB_PASSWORD,required"`
}

func LoadConnectionConfig

func LoadConnectionConfig() (*EnvConfig, error)

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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