etagResponseWriter

package
v0.0.0-...-c6ea6ab Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: LGPL-3.0 Imports: 4 Imported by: 0

README

martini etag http header response middleware

Usage

package main

import (
	"github.com/go-martini/martini"
	"github.com/tsaikd/KDGoLib/martini/etagResponseWriter"
)

func main() {
	m := martini.Classic()
	m.Use(etagResponseWriter.ETagResponseWriter(etagResponseWriter.NewETagConfig()))
	m.Get("/", func() string {
		return "Hello World!"
	})
	m.Run()
}

Reference

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ETagResponseWriter

func ETagResponseWriter(config *ETagConfig) martini.Handler

ETagResponseWriter return martini Handler by ETagConfig

Types

type ETagConfig

type ETagConfig struct {
	MinBodyLength       int
	EnableMethod        map[string]bool
	EnableStatus        map[int]bool
	IgnoreIfHeaderExist map[string]bool
	IgnoreIfHeaderValue map[string]string
	HashFunc            ETagHashFunc
}

ETagConfig config for ETag

func NewETagConfig

func NewETagConfig() *ETagConfig

NewETagConfig return default ETagConfig

func (*ETagConfig) AddIgnoreHeaderExist

func (t *ETagConfig) AddIgnoreHeaderExist(header string, exist bool) *ETagConfig

AddIgnoreHeaderExist ignore etag if header exist

func (*ETagConfig) AddIgnoreHeaderValue

func (t *ETagConfig) AddIgnoreHeaderValue(header string, value string) *ETagConfig

AddIgnoreHeaderValue ignore etag if header equal value

func (*ETagConfig) AddMethod

func (t *ETagConfig) AddMethod(method string) *ETagConfig

AddMethod allow request method for etag

func (*ETagConfig) AddStatus

func (t *ETagConfig) AddStatus(status int) *ETagConfig

AddStatus allow response status for etag

func (*ETagConfig) SetHashFunc

func (t *ETagConfig) SetHashFunc(hashFunc ETagHashFunc) *ETagConfig

SetHashFunc set etag hash function

func (*ETagConfig) SetMinBodyLength

func (t *ETagConfig) SetMinBodyLength(length int) *ETagConfig

SetMinBodyLength if response body size less than length, do not use etag

type ETagHashFunc

type ETagHashFunc func(data []byte) string

ETagHashFunc hash function for generate etag from response body

Jump to

Keyboard shortcuts

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