Skip to content

thedanielforum/apex-gin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Gin middleware for Apex-log

Middleware for gin-gonic and apex-log

GoDoc

Example output

INFO[0005] client_ip=127.0.0.1 latency=168.439199ms method=PUT path=/v1/user/info/123 status_code=200 message=test message

Install

go get https://github.com/thedanielforum/apex-gin-middleware

How to use

// Configure apex-log handler
log.SetHandler(text.New(os.Stderr))

// Configure gin
r := gin.New()

// Tell gin to use apex_gin middleware
r.Use(apex_gin.Handler("test message"))

// Define routes
r.GET("/ping", func(c *gin.Context) {
	c.JSON(200, gin.H{
		"message": "pong",
	})
})

// Start HTTP server
if err := r.Run(":8080"); err != nil {
	log.WithError(err).Fatal("server failed to start")
}

More info about the apex-log package medium

TODO

  • Apex log levels info/warning/error/fatal
  • Unit-testing

Releases

No releases published

Packages

No packages published

Languages