stats

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

cod-stats

Build Status

Route handle stats middleware for cod, it can get some information of route handle, such as status, consuming, size and etc.

package main

import (
	"fmt"
	"net/url"

	"github.com/vicanso/cod"

	proxy "github.com/vicanso/cod-proxy"
	stats "github.com/vicanso/cod-stats"
)

func main() {
	d := cod.New()

	target, _ := url.Parse("https://www.baidu.com")

	d.Use(stats.New(stats.Config{
		OnStats: func(info *stats.Info, _ *cod.Context) {
			fmt.Println(info)
		},
	}))

	d.GET("/*url", proxy.New(proxy.Config{
		Target: target,
		Host:   "www.baidu.com",
	}))

	d.ListenAndServe(":7001")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config Config) cod.Handler

New create a new stats middleware

Types

type Config

type Config struct {
	OnStats OnStats
	Skipper cod.Skipper
}

Config stats config

type Info

type Info struct {
	CID        string
	IP         string
	Method     string
	Route      string
	URI        string
	Status     int
	Consuming  time.Duration
	Type       int
	Size       int
	Connecting uint32
}

Info stats's info

type OnStats

type OnStats func(*Info, *cod.Context)

OnStats on stats function

Jump to

Keyboard shortcuts

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