Help us shape the future of Go! Take the 2026 Go Developer Survey

etag

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2013 License: Apache-2.0 Imports: 1 Imported by: 0

README

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!"))
    } else {
      // you don't need to do anything.
    }
  })
  http.ListenAndServe(":8000", nil)
}

Tests

go test

Documentation

Index

Constants

View Source
const Version = "0.0.2"

Variables

This section is empty.

Functions

func Get

func Get(r *http.Request) string

Get Get the "If-None-Match" from header.

func IsStale

func IsStale(w http.ResponseWriter, r *http.Request, key string) (isStale bool)

IsStale sets the etag on the response and checks it against the client request.

func Set

func Set(w http.ResponseWriter, key string)

Set Sets the etag.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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