go-agent: github.com/sqreen/go-agent/sdk/middleware/sqhttp Index | Files

package sqhttp

import "github.com/sqreen/go-agent/sdk/middleware/sqhttp"

Index

Package Files

http.go

func Middleware Uses

func Middleware(next http.Handler) http.Handler

Middleware is Sqreen's middleware function for `net/http` to monitor and protect received requests. It creates and stores the HTTP request record into the request context so that it can be later accessed to perform SDK calls in the decorated handler using `sdk.FromContext()`.

fn := func(w http.ResponseWriter, r *http.Request) {
	sdk.FromContext(r.Context()).TrackEvent("my.event")
	fmt.Fprintf(w, "OK")
}
http.Handle("/foo", sqhttp.Middleware(http.HandlerFunc(fn)))

Package sqhttp imports 3 packages (graph). Updated 2019-02-07. Refresh now. Tools for package owners.