Skip to content

HTTP header names as golang constants

License

Notifications You must be signed in to change notification settings

xops-infra/http-headers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

http-headers

HTTP headers as golang constants

Install

go get -u github.com/xops-infra/http-headers

Example

package middleware

import (
	"github.com/gin-gonic/gin"
	"github.com/xops-infra/http-headers"
	"net/http"
	"time"
)

// NoCache is a middleware function that appends headers
// to prevent the client from caching the HTTP response.
func NoCache(c *gin.Context) {
	// hh is the package name alias for http-headers
	// hh.CacheControl is a constant inside hh package
	c.Header(hh.CacheControl, "no-cache, no-store, max-age=0, must-revalidate, value")
	c.Header(hh.Expires, "Thu, 01 Jan 1970 00:00:00 GMT")
	c.Header(hh.LastModified, time.Now().UTC().Format(http.TimeFormat))
	c.Next()
}

About

HTTP header names as golang constants

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages