utils

package
Version: v0.0.0-...-2a6385f Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisconnectClient

func DisconnectClient(logger *zap.SugaredLogger, client *mongo.Client)

func FromFormURLEncoded

func FromFormURLEncoded(i interface{}, r map[string][]string) error

FromFormURLEncoded decodes objects form a parsed form

func FromFormURLEncodedRequest

func FromFormURLEncodedRequest(i interface{}, r *http.Request) error

FromFormURLEncodedRequest decodes objects from a form url encoded request

func FromJSON

func FromJSON(i interface{}, r io.Reader) error

FromJSON decodes objects from an io.Reader

func GetIP

func GetIP(r *http.Request) string

GetIP gets a requests IP address by reading off the forwarded-for header (for proxies) and falls back to use the remote address.

func StartGracefully

func StartGracefully(logger *zap.SugaredLogger, server *http.Server, timeoutDuration time.Duration)

StartGracefully starts a http server on another go routine so when an interrupt signal hits, a timout is initialized and all active requests can be handled before shutting down.

func StartGrpcGracefully

func StartGrpcGracefully(logger *zap.SugaredLogger, server *grpc.Server, listener net.Listener)

StartGrpcGracefully starts a grpc server on another go routine so when an interrupt signal hits, a timout is initialized and all active requests can be handled before shutting down.

func StartMongoServer

func StartMongoServer(url, databaseName string, timeout time.Duration) (*mgm.Config, *mongo.Client, *mongo.Database, error)

func StartMongoServerWithFatal

func StartMongoServerWithFatal(logger *zap.SugaredLogger, url, databaseName string, timeout time.Duration) (*mgm.Config, *mongo.Client, *mongo.Database)

func ToJSON

func ToJSON(i interface{}, w io.Writer) error

ToJSON encodes objects and writes them using the specified io.Writer

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL