File: reqctx.go

package info (click to toggle)
golang-github-anacrolix-missinggo 2.1.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 872 kB
  • sloc: makefile: 4
file content (14 lines) | stat: -rw-r--r-- 293 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package reqctx

import (
	"context"
	"net/http"

	"github.com/anacrolix/missinggo/expect"
)

func SetNewValue(r *http.Request, key, value interface{}) *http.Request {
	expect.Nil(r.Context().Value(key))
	expect.NotNil(value)
	return r.WithContext(context.WithValue(r.Context(), key, value))
}