kv

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package kv provide key-value storage.

It more efficient to use this package instead of using context dirrectly for key-value storage, because "net/http.Request.WithContext" always create shallow copy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(r *http.Request, key interface{}) (interface{}, bool)

Get stored value inside kv

func Injector

func Injector(key interface{}, value interface{}) func(http.HandlerFunc) http.HandlerFunc

Injector return middleware to set value with the key

func MustGet

func MustGet(r *http.Request, key interface{}) interface{}

MustGet do the same thing as Get, but will panic if it never set before

func WithValue

func WithValue(r *http.Request, key interface{}, value interface{}) *http.Request

WithValue will return request that have kv instance in its context, and also set kv entry with provided key and value

Types

This section is empty.

Jump to

Keyboard shortcuts

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