revision

package module
v0.0.0-...-cc548e4 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2016 License: MIT Imports: 4 Imported by: 2

README

gin-revision-middleware

Revision middleware for Gin framework written in Go (Golang).

Build Status Build Status Go Report Card Coverage Status codecov

How to use

Please see the demo code and creat REVISION file and write your application version into file.

package main

import (
  "github.com/appleboy/gin-revision-middleware"
  "github.com/gin-gonic/gin"
  "net/http"
  "os"
)

func rootHandler(context *gin.Context) {
  context.JSON(http.StatusOK, gin.H{
    "Hello": "world",
  })
}

func main() {
  port := os.Getenv("PORT")
  router := gin.Default()
  if port == "" {
    port = "8000"
  }
  router.Use(revision.Middleware())
  router.GET("/", rootHandler)
  router.Run(":" + port)
}

Screenshot for header

header screenshot

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRevision

func GetRevision(fileName string) (string, error)

GetRevision will get revision string from file.

func Middleware

func Middleware(args ...string) gin.HandlerFunc

Middleware will auto set Revision on header.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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