utils

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logging

func Logging() func(http.Handler) http.Handler

Logging wraps an http handler and returns a new handler that prints request log.

func NewUUID added in v0.3.2

func NewUUID() (uuid, error)

NewUUID creates a new uuid.

func NewUUIDShort added in v0.3.2

func NewUUIDShort() (string, error)

NewUUIDShort creates a new uuid and encodes it to a short form.

func Randstr

func Randstr(n int) string

Randstr generates a random string

func ReadIP

func ReadIP(r *http.Request) (ip string)

ReadIP implements a best effort approach to return the real client IP, it parses X-Real-IP and X-Forwarded-For in order to work properly with reverse-proxies such us: nginx or haproxy. Use X-Forwarded-For before X-Real-Ip as nginx uses X-Real-Ip with the proxy's IP.

The purpose of this function is to produce an identifier of visitor. It does not matter wheather it is an real IP or not. Depending on the configuration, the returned IP address might be an encrypted hash string.

This implementation is derived from gin-gonic/gin.

Types

This section is empty.

Jump to

Keyboard shortcuts

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