requestid

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Options) gear.Middleware

New creates a middleware to return X-Request-ID header

package main

import (
	"github.com/teambition/gear"
	"github.com/teambition/gear/middleware/requestid"
)

func main() {
	app := gear.New()
	app.Use(requestid.New())
	app.Use(func(ctx *gear.Context) error {
		return ctx.HTML(200, "<h1>Hello, Gear!</h1>")
	})
	app.Error(app.Listen(":3000"))
}

Types

type Options

type Options struct {
	// Generator defines a function to generate the requestID.
	// Optional. Default generate uuid v4 string.
	Generator func() string
}

Jump to

Keyboard shortcuts

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