Skip to content

t-k/etag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

etag

Build Status

Provide etag support for Go web server.

How to install

go get github.com/t-k/etag

Usage

Install the package with go get and use import to include it in your project.

import "github.com/t-k/etag"

GoDoc: http://godoc.org/github.com/t-k/etag

##Example

package main

import (
	"github.com/t-k/etag"
	"net/http"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if etag.IsStale(w, r, "etag-key") {
			// normal response processing
			w.Write([]byte("Hello world!"))
		}
		// If the request is fresh (i.e. it's not modified) then you don't need to do anything.
		// IsStale automatically send a "304 Not Modified"
	})
	http.ListenAndServe(":8000", nil)
}

Tests

go test

About

Provide etag support for Go web server.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages