hh

package module
v0.0.0-...-8fabae2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 0 Imported by: 1

README

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()
}

Documentation

Index

Constants

View Source
const (
	AIM                           = "A-IM"
	Accept                        = "Accept"
	AcceptCH                      = "Accept-CH"
	AcceptCharset                 = "Accept-Charset"
	AcceptDatetime                = "Accept-Datetime"
	AcceptEncoding                = "Accept-Encoding"
	AcceptLanguage                = "Accept-Language"
	AcceptPatch                   = "Accept-Patch"
	AcceptRanges                  = "Accept-Ranges"
	AccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	AccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	AccessControlAllowMethods     = "Access-Control-Allow-Methods"
	AccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	AccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	AccessControlMaxAge           = "Access-Control-Max-Age"
	AccessControlRequestHeaders   = "Access-Control-Request-Headers"
	AccessControlRequestMethod    = "Access-Control-Request-Method"
	Age                           = "Age"
	Allow                         = "Allow"
	AltSvc                        = "Alt-Svc"
	Authorization                 = "Authorization"
	CacheControl                  = "Cache-Control"
	Connection                    = "Connection"
	ContentDisposition            = "Content-Disposition"
	ContentEncoding               = "Content-Encoding"
	ContentLanguage               = "Content-Language"
	ContentLength                 = "Content-Length"
	ContentLocation               = "Content-Location"
	ContentMD5                    = "Content-MD5"
	ContentRange                  = "Content-Range"
	ContentType                   = "Content-Type"
	Cookie                        = "Cookie"
	Date                          = "Date"
	DeltaBase                     = "Delta-Base"
	ETag                          = "ETag"
	Expect                        = "Expect"
	Expires                       = "Expires"
	Forwarded                     = "Forwarded"
	From                          = "From"
	Host                          = "Host"
	IM                            = "IM"
	IfMatch                       = "If-Match"
	IfModifiedSince               = "If-Modified-Since"
	IfNoneMatch                   = "If-None-Match"
	IfRange                       = "If-Range"
	IfUnmodifiedSince             = "If-Unmodified-Since"
	LastModified                  = "Last-Modified"
	Link                          = "Link"
	Location                      = "Location"
	MaxForwards                   = "Max-Forwards"
	Origin                        = "Origin"
	P3P                           = "P3P"
	PreferenceApplied             = "Preference-Applied"
	Prefer                        = "Prefer"
	ProxyAuthenticate             = "Proxy-Authenticate"
	ProxyAuthorization            = "Proxy-Authorization"
	PublicKeyPins                 = "Public-Key-Pins"
	Range                         = "Range"
	Referer                       = "Referer"
	RetryAfter                    = "Retry-After"
	Server                        = "Server"
	SetCookie                     = "Set-Cookie"
	StrictTransportSecurity       = "Strict-Transport-Security"
	TE                            = "TE"
	Trailer                       = "Trailer"
	TransferEncoding              = "Transfer-Encoding"
	Tk                            = "Tk"
	Upgrade                       = "Upgrade"
	UserAgent                     = "User-Agent"
	Vary                          = "Vary"
	Via                           = "Via"
	Warning                       = "Warning"
	WWWAuthenticate               = "WWW-Authenticate"
	XFrameOptions                 = "X-Frame-Options"
)

Standard request field names

View Source
const (
	ContentSecurityPolicy   = "Content-Security-Policy"
	CorrelationID           = "Correlation-ID"
	DNT                     = "DNT"
	ExpectCT                = "Expect-CT"
	FrontEndHttps           = "Front-End-Https"
	NEL                     = "NEL"
	PermissionsPolicy       = "Permissions-Policy"
	ProxyConnection         = "Proxy-Connection"
	Refresh                 = "Refresh"
	ReportTo                = "Report-To"
	SaveData                = "Save-Data"
	Status                  = "Status"
	TimingAllowOrigin       = "Timing-Allow-Origin"
	UpgradeInsecureRequests = "Upgrade-Insecure-Requests"
	XAttDeviceId            = "X-ATT-DeviceId"
	XContentDuration        = "X-Content-Duration"
	XContentSecurityPolicy  = "X-Content-Security-Policy"
	XContentTypeOptions     = "X-Content-Type-Options"
	XCorrelationID          = "X-CorrelationID"
	XCsrfToken              = "X-Csrf-Token"
	XForwardedFor           = "X-Forwarded-For"
	XForwardedHost          = "X-Forwarded-Host"
	XForwardedProto         = "X-Forwarded-Proto"
	XHttpMethodOverride     = "X-Http-Method-Override"
	XPoweredBy              = "X-Powered-By"
	XRedirectBy             = "X-Redirect-By"
	XRequestedWith          = "X-Requested-With"
	XRequestID              = "X-Request-ID"
	XUAcompatible           = "X-UA-Compatible"
	XXSSProtection          = "X-XSS-Protection"
	XWapProfile             = "X-Wap-Profile"
	XWebKitCSP              = "X-WebKit-CSP"
	XUidh                   = "X-UIDH"
)

Common non-standard field names

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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