Categorygithub.com/mnwa/fasthttprouter-prometheus
repositorypackage
0.0.0-20190920114442-a12d40b15b9e
Repository: https://github.com/mnwa/fasthttprouter-prometheus.git
Documentation: pkg.go.dev

# README

fasthttp-prometheus

Prometheus metrics exporter for go fasthttp/router

Installation

$ go get github.com/Mnwa/fasthttprouter-prometheus

Usage

package main

import (
    "fmt"
    "github.com/fasthttp/router"
    "github.com/valyala/fasthttp"
    "github.com/Mnwa/fasthttprouter-prometheus"
    "log"
)

func Index(ctx *fasthttp.RequestCtx) {
    fmt.Fprint(ctx, "Welcome!\n")
}

func main() {
    r := router.New()
    APIregist(r)

    p := fasthttprouter_prometheus.NewPrometheus("fasthttp")
    fastpHandler := p.WrapHandler(r)

    log.Fatal(fasthttp.ListenAndServe(":8080", fastpHandler))
}

func APIregist(r *fasthttprouter.Router) {
    r.GET("/", Index)
}

Related Project

Inspired by