ginprom

package
v1.0.26 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Example
package main

import (
	"github.com/boxgo/box/pkg/logger"
	"github.com/boxgo/box/pkg/server/ginserver"
	"github.com/boxgo/box/pkg/server/ginserver/mid/ginprom"
	"github.com/gin-gonic/gin"
)

func main() {
	ginserver.Use(ginprom.Handler())
	ginserver.GET("/ping", func(ctx *gin.Context) {
		ctx.Data(200, "text/plain", []byte("pong"))
	})

	if err := ginserver.Run(); err != nil {
		logger.Fatal(err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Default = StdConfig("default").Build()
)

Functions

func Handler

func Handler() gin.HandlerFunc

func UrlMapping

func UrlMapping(c *gin.Context) string

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config 配置

func DefaultConfig

func DefaultConfig(key string) *Config

DefaultConfig 默认配置

func StdConfig

func StdConfig(key string, optionFunc ...OptionFunc) *Config

StdConfig 标准配置

func (*Config) Build

func (c *Config) Build() *GinProm

Build 构建实例

func (*Config) Path

func (c *Config) Path() string

Path 实例配置目录

type GinProm

type GinProm struct {
	// contains filtered or unexported fields
}

func (*GinProm) Handler

func (prom *GinProm) Handler() gin.HandlerFunc

type OptionFunc

type OptionFunc func(*Config)

OptionFunc 选项信息

func WithURLMapping

func WithURLMapping(fn func(*gin.Context) string) OptionFunc

WithURLMapping set up url mapping func default is: UrlMapping

Jump to

Keyboard shortcuts

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