Documentation ¶
Overview ¶
Package ginhelper provides some common functionality across gin servers.
Index ¶
- Constants
- Variables
- func BeautifyJSONBytes(data []byte, hiddenFields []string) ([]byte, error)
- func Dump() gin.HandlerFunc
- func DumpWithOptions(showReq bool, showResp bool, showBody bool, showHeaders bool, showCookies bool, ...) gin.HandlerFunc
- func FormatToBeautifulJSON(v interface{}, hiddenFields []string) ([]byte, error)
- func New(logger *log.ZapEventLogger) *gin.Engine
- func NewWithExperimentalLogger(ctx context.Context, logger logger.ExperimentalLogger) *gin.Engine
- func TraceMiddleware(tracer trace.Tracer, printStr bool) gin.HandlerFunc
- func WaitForStart(parentCtx context.Context, port int) error
Constants ¶
const HealthCheck string = "/health-check"
HealthCheck is the health check endpoint.
const MetricsEndpoint string = "/metrics"
MetricsEndpoint is used for prometheus metrics. Deprecated: use METRICS_PATH instead.
const RequestIDHeader = "X-Request-ID"
RequestIDHeader is used for tracking request ids.
const RobotsTxt string = "/robots.txt"
RobotsTxt is used for apis to disallow crawls.
Variables ¶
var Indent = 4
Indent is the number of spaces to indent.
var Newline = "\n"
Newline is the string to use for newlines.
var StringMaxLength = 0
StringMaxLength is the maximum length of a string to display.
Functions ¶
func BeautifyJSONBytes ¶ added in v0.5.2
BeautifyJSONBytes beautifies json bytes.
func DumpWithOptions ¶ added in v0.5.2
func DumpWithOptions(showReq bool, showResp bool, showBody bool, showHeaders bool, showCookies bool, cb func(dumpStr string)) gin.HandlerFunc
DumpWithOptions dumps the request and response with options. nolint: gocognit, nestif, cyclop
func FormatToBeautifulJSON ¶ added in v0.5.2
FormatToBeautifulJSON dumps v to beautified json bytes.
func New ¶
New creates a new gin server with some sensible defaults. these include: - helmet-default handlers - request-ids (used for stack tracing) - cors (used for requests from the frontend) - health-checks - restrictive robots.txt.
func NewWithExperimentalLogger ¶ added in v0.1.12
NewWithExperimentalLogger creates a new gin server with some sensible defaults. See New for more information.
func TraceMiddleware ¶ added in v0.5.2
func TraceMiddleware(tracer trace.Tracer, printStr bool) gin.HandlerFunc
TraceMiddleware is a middleware that traces the request/response.
Types ¶
This section is empty.