Documentation
¶
Index ¶
- Constants
- func Build(opts HeaderOpts) map[string]string
- type Accept
- type AcceptEncoding
- type AcceptLanguage
- type AccessControlAllowCredentials
- type AccessControlAllowHeaders
- type AccessControlAllowMethods
- type AccessControlAllowOrigin
- type AccessControlMaxAge
- type Authorization
- type Builder
- type CacheControl
- type Connection
- type ContentDisposition
- type ContentType
- type DNT
- type HeaderOpts
- type OptionsBuilder
- type Pragma
- type Range
- type SecCHPrefersColorScheme
- type SecCHPrefersReducedMotion
- type SecCHUAMobile
- type SecCHUAPlatform
- type SecFetchDest
- type SecFetchMode
- type SecFetchSite
- type SecFetchUser
- type StrictTransportSecurity
- type TE
- type TransferEncoding
- type Upgrade
- type UserAgent
- type XContentTypeOptions
- type XFrameOptions
- type XRequestedWith
Constants ¶
const ( // Browser information BrowserName = "Chrome" ChromeVersion = "139" ChromeVersionFull = ChromeVersion + ".0.7258.66" UserAgentDefault = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/" + ChromeVersion + ".0.0.0 Safari/537.36" SecCHUserAgentDefault = `"Chromium";v="` + ChromeVersion + `", "Google Chrome";v="` + ChromeVersion + `", "Not-A.Brand";v="99"` SecCHFullVersionDefault = `"Chromium";v="` + ChromeVersionFull + `", "Google Chrome";v="` + ChromeVersionFull + `", "Not-A.Brand";v="99.0.0.0"` // Platform information OSName = "Linux" OSVersion = "6.8.0" SecCHPlatformDefault = `"` + OSName + `"` SecCHPlatformVersionDefault = `"` + OSVersion + `"` SecCHMobileDefault = "?0" SecCHModelDefault = "" SecCHPrefersColorSchemeDefault = "light" // System identifier UDID = OSName + "/" + BrowserName )
Browser and Platform Constants
const ( AcceptDefault = "*/*" AcceptLanguageDefault = "en-US,en;q=0.9" AcceptEncodingDefault = "gzip, deflate, br, zstd" ConnectionDefault = "keep-alive" )
Common Header Values
const ( AccessControlAllowOriginAll AccessControlAllowOrigin = "*" AccessControlAllowMethodsAll AccessControlAllowMethods = "*" AccessControlAllowMethodsCommon AccessControlAllowMethods = "GET, POST, PUT, DELETE, OPTIONS" AccessControlAllowHeadersAll AccessControlAllowHeaders = "*" AccessControlAllowHeadersCommon AccessControlAllowHeaders = "Content-Type, Authorization, X-Requested-With" AccessControlAllowCredentialsTrue AccessControlAllowCredentials = "true" AccessControlAllowCredentialsFalse AccessControlAllowCredentials = "false" AccessControlMaxAgeOneHour AccessControlMaxAge = "3600" AccessControlMaxAgeOneDay AccessControlMaxAge = "86400" )
CORS Constants
const ( SecCHUAMobileDesktop SecCHUAMobile = "?0" SecCHUAMobileMobile SecCHUAMobile = "?1" SecCHUAPlatformWindows SecCHUAPlatform = `"Windows"` SecCHUAPlatformMacOS SecCHUAPlatform = `"macOS"` SecCHUAPlatformLinux SecCHUAPlatform = `"Linux"` SecCHUAPlatformAndroid SecCHUAPlatform = `"Android"` SecCHUAPlatformiOS SecCHUAPlatform = `"iOS"` SecCHPrefersColorSchemeLight SecCHPrefersColorScheme = "light" SecCHPrefersColorSchemeDark SecCHPrefersColorScheme = "dark" SecCHPrefersReducedMotionNoPreference SecCHPrefersReducedMotion = "no-preference" SecCHPrefersReducedMotionReduce SecCHPrefersReducedMotion = "reduce" )
Client Hints Constants
const ( HeaderAPIKey = "X-API-Key" HeaderAPIVersion = "X-API-Version" HeaderRequestID = "X-Request-ID" HeaderTimestamp = "X-Timestamp" HeaderSignature = "X-Signature" HeaderNonce = "X-Nonce" HeaderRateLimit = "X-RateLimit-Limit" HeaderRateLimitRemaining = "X-RateLimit-Remaining" HeaderRateLimitReset = "X-RateLimit-Reset" )
Custom API Header Names (commonly used)
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(opts HeaderOpts) map[string]string
Types ¶
type Accept ¶
type Accept string
Accept represents the Accept header value
const ( AcceptAll Accept = "*/*" AcceptJSON Accept = "application/json" AcceptXML Accept = "application/xml" AcceptHTML Accept = "text/html" AcceptText Accept = "text/plain" AcceptImage Accept = "image/*" AcceptAudio Accept = "audio/*" AcceptVideo Accept = "video/*" AcceptJSONXML Accept = "application/json, application/xml" AcceptHTMLXHTML Accept = "text/html, application/xhtml+xml" AcceptImageWebP Accept = "image/webp,image/apng,image/*,*/*;q=0.8" )
Accept Constants
type AcceptEncoding ¶
type AcceptEncoding string
AcceptEncoding represents the Accept-Encoding header value
const ( AcceptEncodingAll AcceptEncoding = "gzip, deflate, br, zstd" AcceptEncodingGzip AcceptEncoding = "gzip" AcceptEncodingDeflate AcceptEncoding = "deflate" AcceptEncodingBrotli AcceptEncoding = "br" AcceptEncodingZstd AcceptEncoding = "zstd" AcceptEncodingIdentity AcceptEncoding = "identity" )
AcceptEncoding Constants
type AcceptLanguage ¶
type AcceptLanguage string
AcceptLanguage represents the Accept-Language header value
const ( AcceptLanguageEnglish AcceptLanguage = "en-US,en;q=0.9" AcceptLanguageSpanish AcceptLanguage = "es-ES,es;q=0.9" AcceptLanguageFrench AcceptLanguage = "fr-FR,fr;q=0.9" AcceptLanguageGerman AcceptLanguage = "de-DE,de;q=0.9" AcceptLanguageChinese AcceptLanguage = "zh-CN,zh;q=0.9" AcceptLanguageJapanese AcceptLanguage = "ja-JP,ja;q=0.9" AcceptLanguageUniversal AcceptLanguage = "en-US,en;q=0.9,*;q=0.5" )
AcceptLanguage Constants
type AccessControlAllowCredentials ¶
type AccessControlAllowCredentials string
AccessControlAllowCredentials represents the Access-Control-Allow-Credentials header value
type AccessControlAllowHeaders ¶
type AccessControlAllowHeaders string
AccessControlAllowHeaders represents the Access-Control-Allow-Headers header value
type AccessControlAllowMethods ¶
type AccessControlAllowMethods string
AccessControlAllowMethods represents the Access-Control-Allow-Methods header value
type AccessControlAllowOrigin ¶
type AccessControlAllowOrigin string
AccessControlAllowOrigin represents the Access-Control-Allow-Origin header value
type AccessControlMaxAge ¶
type AccessControlMaxAge string
AccessControlMaxAge represents the Access-Control-Max-Age header value
type Authorization ¶
type Authorization string
Authorization represents the Authorization header value
const ( AuthorizationBearerPrefix Authorization = "Bearer " AuthorizationBasicPrefix Authorization = "Basic " AuthorizationDigestPrefix Authorization = "Digest " AuthorizationOAuth Authorization = "OAuth " AuthorizationAPIKey Authorization = "ApiKey " )
Authorization Constants
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a reusable builder for basic headers
func NewBuilder ¶
NewBuilder creates a new Builder with custom basic headers
func (*Builder) Build ¶
func (hb *Builder) Build(opt HeaderOpts) map[string]string
Build constructs the final headers map, merging basic headers with HeaderOpts
func (*Builder) RemoveBasicHeader ¶
RemoveBasicHeader removes a basic header
func (*Builder) SetBasicHeader ¶
SetBasicHeader sets or updates a basic header that will be included in every build
type CacheControl ¶
type CacheControl string
CacheControl represents the Cache-Control header value
const ( CacheControlNoCache CacheControl = "no-cache" CacheControlNoStore CacheControl = "no-store" CacheControlMaxAge0 CacheControl = "max-age=0" CacheControlMaxAge3600 CacheControl = "max-age=3600" CacheControlMaxAge86400 CacheControl = "max-age=86400" CacheControlMustRevalidate CacheControl = "must-revalidate" CacheControlPublic CacheControl = "public" CacheControlPrivate CacheControl = "private" CacheControlImmutable CacheControl = "immutable" CacheControlStaleWhileRevalidate CacheControl = "stale-while-revalidate=86400" )
CacheControl Constants
type Connection ¶
type Connection string
Connection represents the Connection header value
const ( ConnectionKeepAlive Connection = "keep-alive" ConnectionClose Connection = "close" ConnectionUpgrade Connection = "upgrade" )
Connection Constants
type ContentDisposition ¶
type ContentDisposition string
ContentDisposition represents the Content-Disposition header value
const ( ContentDispositionInline ContentDisposition = "inline" ContentDispositionAttachment ContentDisposition = "attachment" ContentDispositionFormData ContentDisposition = "form-data" )
Content Disposition Constants
type ContentType ¶
type ContentType string
ContentType represents the Content-Type header value
const ( // JSON content types ContentTypeJSON ContentType = "application/json" ContentTypeJSONUTF8 ContentType = "application/json; charset=utf-8" // XML content types ContentTypeXML ContentType = "application/xml" ContentTypeXMLUTF8 ContentType = "application/xml; charset=utf-8" // Form content types ContentTypeForm ContentType = "application/x-www-form-urlencoded" ContentTypeFormUTF8 ContentType = "application/x-www-form-urlencoded; charset=utf-8" ContentTypeMultipart ContentType = "multipart/form-data" ContentTypeMultipartPrefix ContentType = "multipart/form-data; boundary=" // Text content types ContentTypeTextPlain ContentType = "text/plain" ContentTypeTextPlainUTF8 ContentType = "text/plain; charset=utf-8" ContentTypeTextHTML ContentType = "text/html" ContentTypeTextHTMLUTF8 ContentType = "text/html; charset=utf-8" ContentTypeTextCSS ContentType = "text/css" ContentTypeTextJavaScript ContentType = "text/javascript" ContentTypeTextXML ContentType = "text/xml" ContentTypeTextCSV ContentType = "text/csv" // Binary content types ContentTypeApplicationOctet ContentType = "application/octet-stream" ContentTypeApplicationPDF ContentType = "application/pdf" ContentTypeApplicationZip ContentType = "application/zip" ContentTypeApplicationGzip ContentType = "application/gzip" // Image content types ContentTypeImageJPEG ContentType = "image/jpeg" ContentTypeImagePNG ContentType = "image/png" ContentTypeImageGIF ContentType = "image/gif" ContentTypeImageWebP ContentType = "image/webp" ContentTypeImageSVG ContentType = "image/svg+xml" ContentTypeImageICO ContentType = "image/x-icon" ContentTypeImageBMP ContentType = "image/bmp" ContentTypeImageTIFF ContentType = "image/tiff" // Audio content types ContentTypeAudioMP3 ContentType = "audio/mpeg" ContentTypeAudioWAV ContentType = "audio/wav" ContentTypeAudioOGG ContentType = "audio/ogg" ContentTypeAudioAAC ContentType = "audio/aac" ContentTypeAudioFLAC ContentType = "audio/flac" // Video content types ContentTypeVideoMP4 ContentType = "video/mp4" ContentTypeVideoAVI ContentType = "video/x-msvideo" ContentTypeVideoMOV ContentType = "video/quicktime" ContentTypeVideoWEBM ContentType = "video/webm" ContentTypeVideoOGV ContentType = "video/ogg" )
ContentType Constants
type HeaderOpts ¶
type HeaderOpts struct {
ContentType ContentType
Accept Accept
AcceptLanguage AcceptLanguage
AcceptEncoding AcceptEncoding
Connection Connection
UserAgent UserAgent
Referer string
Origin string
Host string
Authorization Authorization
CacheControl CacheControl
Pragma Pragma
DNT DNT
SecFetchDest SecFetchDest
SecFetchMode SecFetchMode
SecFetchSite SecFetchSite
SecFetchUser SecFetchUser
XRequestedWith XRequestedWith
XFrameOptions XFrameOptions
XContentTypeOptions XContentTypeOptions
XCSRFToken string
StrictTransportSecurity StrictTransportSecurity
ContentSecurityPolicy string
AccessControlAllowOrigin AccessControlAllowOrigin
AccessControlAllowMethods AccessControlAllowMethods
AccessControlAllowHeaders AccessControlAllowHeaders
Range Range
IfModifiedSince string
IfNoneMatch string
ContentDisposition ContentDisposition
Custom map[string]string
IncludeSecUserAgent bool // Include Sec-CH-* headers
}
HeaderOpts contains options for building headers using custom types
type OptionsBuilder ¶
type OptionsBuilder struct {
// contains filtered or unexported fields
}
OptionsBuilder provides a fluent interface for building HeaderOpts
type Range ¶
type Range string
Range represents the Range header value
const (
RangeBytes Range = "bytes="
)
Range Constants
type SecCHPrefersColorScheme ¶
type SecCHPrefersColorScheme string
SecCHPrefersColorScheme represents the Sec-CH-Prefers-Color-Scheme header value
type SecCHPrefersReducedMotion ¶
type SecCHPrefersReducedMotion string
SecCHPrefersReducedMotion represents the Sec-CH-Prefers-Reduced-Motion header value
type SecCHUAMobile ¶
type SecCHUAMobile string
SecCHUAMobile represents the Sec-CH-UA-Mobile header value
type SecCHUAPlatform ¶
type SecCHUAPlatform string
SecCHUAPlatform represents the Sec-CH-UA-Platform header value
type SecFetchDest ¶
type SecFetchDest string
SecFetchDest represents the Sec-Fetch-Dest header value
const ( SecFetchDestEmpty SecFetchDest = "empty" SecFetchDestDocument SecFetchDest = "document" SecFetchDestImage SecFetchDest = "image" SecFetchDestScript SecFetchDest = "script" SecFetchDestStyle SecFetchDest = "style" SecFetchDestAudio SecFetchDest = "audio" SecFetchDestVideo SecFetchDest = "video" SecFetchDestFont SecFetchDest = "font" SecFetchDestFrame SecFetchDest = "frame" SecFetchDestIFrame SecFetchDest = "iframe" SecFetchDestManifest SecFetchDest = "manifest" SecFetchDestObject SecFetchDest = "object" SecFetchDestServiceWorker SecFetchDest = "serviceworker" SecFetchDestWorker SecFetchDest = "worker" )
SecFetchDest Constants
type SecFetchMode ¶
type SecFetchMode string
SecFetchMode represents the Sec-Fetch-Mode header value
const ( SecFetchModeCORS SecFetchMode = "cors" SecFetchModeNoCORS SecFetchMode = "no-cors" SecFetchModeSameOrigin SecFetchMode = "same-origin" SecFetchModeWebSocket SecFetchMode = "websocket" )
SecFetchMode Constants
type SecFetchSite ¶
type SecFetchSite string
SecFetchSite represents the Sec-Fetch-Site header value
const ( SecFetchSiteCrossOrigin SecFetchSite = "cross-origin" SecFetchSiteSameOrigin SecFetchSite = "same-origin" SecFetchSiteSameSite SecFetchSite = "same-site" SecFetchSiteNone SecFetchSite = "none" )
SecFetchSite Constants
type SecFetchUser ¶
type SecFetchUser string
SecFetchUser represents the Sec-Fetch-User header value
const ( SecFetchUserTrue SecFetchUser = "?1" SecFetchUserFalse SecFetchUser = "?0" )
SecFetchUser Constants
type StrictTransportSecurity ¶
type StrictTransportSecurity string
StrictTransportSecurity represents the Strict-Transport-Security header value
const ( StrictTransportSecurityMaxAge StrictTransportSecurity = "max-age=31536000" StrictTransportSecurityIncludeSub StrictTransportSecurity = "max-age=31536000; includeSubDomains" StrictTransportSecurityPreload StrictTransportSecurity = "max-age=31536000; includeSubDomains; preload" )
Security Header Constants
type TransferEncoding ¶
type TransferEncoding string
TransferEncoding represents the Transfer-Encoding header value
const ( TransferEncodingChunked TransferEncoding = "chunked" TransferEncodingCompress TransferEncoding = "compress" TransferEncodingDeflate TransferEncoding = "deflate" TransferEncodingGzip TransferEncoding = "gzip" TransferEncodingIdentity TransferEncoding = "identity" )
Transfer Encoding Constants
type UserAgent ¶
type UserAgent string
UserAgent represents the User-Agent header value
const ( UserAgentChrome UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36" UserAgentFirefox UserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0" UserAgentSafari UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Safari/605.1.15" UserAgentEdge UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0" UserAgentMobile UserAgent = "" /* 135-byte string literal not displayed */ UserAgentBot UserAgent = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" )
Common User Agents
type XContentTypeOptions ¶
type XContentTypeOptions string
XContentTypeOptions represents the X-Content-Type-Options header value
const (
XContentTypeOptionsNoSniff XContentTypeOptions = "nosniff"
)
XContentTypeOptions Constants
type XFrameOptions ¶
type XFrameOptions string
XFrameOptions represents the X-Frame-Options header value
const ( XFrameOptionsDeny XFrameOptions = "DENY" XFrameOptionsSameOrigin XFrameOptions = "SAMEORIGIN" XFrameOptionsAllowFrom XFrameOptions = "ALLOW-FROM" )
XFrameOptions Constants
type XRequestedWith ¶
type XRequestedWith string
XRequestedWith represents the X-Requested-With header value
const ( XRequestedWithXMLHttpRequest XRequestedWith = "XMLHttpRequest" XRequestedWithFlash XRequestedWith = "ShockwaveFlash" )
XRequestedWith Constants