pdns-auth-proxy/vendor/github.com/jarcoal/httpmock/internal/submatches.go

23 lines
446 B
Go
Raw Normal View History

2023-11-17 05:55:06 +00:00
package internal
import (
"context"
"net/http"
)
type submatchesKeyType struct{}
var submatchesKey submatchesKeyType
func SetSubmatches(req *http.Request, submatches []string) *http.Request {
if len(submatches) > 0 {
return req.WithContext(context.WithValue(req.Context(), submatchesKey, submatches))
}
return req
}
func GetSubmatches(req *http.Request) []string {
sm, _ := req.Context().Value(submatchesKey).([]string)
return sm
}