Skip to content

Makepad-fr/gam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gam

Go Reference Go Report Card

An analytics middleware for Go web servers

Install

TIP: If you want to use a specific version please refer releases and replace latest with the desired version.

go get -u https://github.com/Makepad-fr/gam@latest

Usage

First create a new instance of gam by using the gam.Init function

g, err := gam.Init("ch_username", "ch_password", "ch_hostname", "ch_port", "ch_database_name", "ch_table_name", true, true)

This will return an error if there's a connection issue or if the table names ch_table_name exists but have a different schema then the expected schema. Otherwise it will create an table named ch_table_name if it does not exists yet.

Then pass your handler function to the g.Middleware as you'd done with any middleware functions in go

h := g.Middleware(myHandlerFunc)

It will create you a http.Handler that you can pass to a http.ServerMux or http.Server using Handle method