evercookie

package module
v0.0.0-...-09fafeb Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: MIT Imports: 7 Imported by: 0

README

Evercookie Middleware for Golang

Build Status

Evercookie is a Javascript API that produces extremely persistent cookies in a browser. It is written in JavaScript and additionally uses a SWF (Flash) object for the Local Shared Objects and, originally, PHPs for the server-side generation of cached PNGs and ETags.

This middleware port original PHP script to Golang

Go version support

1.0+

Install

go get go-evercookie

Usage

@todo

Settings

Customized settings can be used, but up to this moment, it makes no sense to change the default one, as all these values are hardcoded in (frontend) evercookie.js. @todo

Test

go test

Acknowledgement

License

The MIT License (MIT) Copyright (c) 2015 TruongSinh Tran-Nguyen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Evercookie

func Evercookie(config *Config) func(http.ResponseWriter, *http.Request, func())

*

Types

type Config

type Config struct {
	EtagCookieName  string
	CacheCookieName string
	AuthPath        string
	PngPath         string
	EtagPath        string
	CachePath       string
}
func setCache(etag string, w web.ResponseWriter) {
	const cacheControlKey = "Cache-Control"
	h := w.Header()
	h.Set("Etag", etag)
	if h.Get(cacheControlKey) == "" {
		// only set cache control if there is none before
		// cache it ~ 1 month, as we revision almost all of our assets
		// 3000000 = 3e6s = 1.1408 month
		h.Set(cacheControlKey, "public, max-age=3000000")
	}
	return
}

func DefaultConfig

func DefaultConfig() *Config

Jump to

Keyboard shortcuts

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