utils

package
v0.0.0-...-ce44bb8 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Conf = New()
View Source
var Logger *zap.Logger

Logger instance

Functions

func Error

func Error(r *http.Request, err error)

Error logs error with pre-defined fields.

func Info

func Info(r *http.Request, s string)

Info logs request info with pre-defined fields.

func IsOnBlackList

func IsOnBlackList(s string) (bool, error)

IsOnBlackList checks wether the url is on the blacklist or not.

func IsURL

func IsURL(s string) (bool, error)

IsURL check if the string is an URL.

func ReOrderQuery

func ReOrderQuery(s string) string

ReOrderQuery orders url query for hash consistency.

func SetupLogger

func SetupLogger(l *lumberjack.Logger) *zap.Logger

SetupLogger initialize a zap logger instance.

Types

type Config

type Config struct {
	Database db     `yaml:"database"`
	Log      log    `yaml:"log"`
	Server   server `yaml:"server"`
}

Config is a yaml structure for managing config.

func New

func New() *Config

New creates a pointer to the configuration struct

func (*Config) ReadConfig

func (c *Config) ReadConfig()

ReadConfig checks if the configuration file exists. If it exists than unmarshal it to a structure. Else, create one with default settings and exit(0).

Jump to

Keyboard shortcuts

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