healthcheck

package module
v0.0.0-...-33bb1af Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: MIT Imports: 5 Imported by: 0

README

Healthcheck

Build Status codecov GoDoc Go Report Card FOSSA Status

Healthcheck helper for Gin to be able to easily got health checked thoroughly by Consul

Usage

Download and install it:

go get github.com/JesusIslam/healthcheck

Import it in your code:

import "github.com/JesusIslam/healthcheck

Simplest default example:

package main

import (
    "time"

    "github.com/JesusIslam/healthcheck"
    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.Default()

    timeout := 15 * time.Second
    h := healthcheck.New(nil, "myauthtoken", timeout)
    r.GET("/health", h.Handle)

    r.Run(":8080")
}

Documentation

Index

Constants

View Source
const (
	DefaultAuthToken = "healthcheck"
	DefaultTimeout   = time.Second * 30

	AuthHeaderKey = "Authorization"

	SuccessFormat = "OK"
	ErrorFormat   = "ERROR: %v"

	InvalidTokenMessage = "invalid token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Healthcheck

type Healthcheck struct {
	Checker   check.Checker
	AuthToken string
	Timeout   time.Duration
}

func New

func New(checker check.Checker, authToken string, timeout time.Duration) *Healthcheck

func (*Healthcheck) Handle

func (h *Healthcheck) Handle(c *gin.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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