...

Source file src/github.com/jarcoal/httpmock/internal/submatches.go

Documentation: github.com/jarcoal/httpmock/internal

     1  package internal
     2  
     3  import (
     4  	"context"
     5  	"net/http"
     6  )
     7  
     8  type submatchesKeyType struct{}
     9  
    10  var submatchesKey submatchesKeyType
    11  
    12  func SetSubmatches(req *http.Request, submatches []string) *http.Request {
    13  	if len(submatches) > 0 {
    14  		return req.WithContext(context.WithValue(req.Context(), submatchesKey, submatches))
    15  	}
    16  	return req
    17  }
    18  
    19  func GetSubmatches(req *http.Request) []string {
    20  	sm, _ := req.Context().Value(submatchesKey).([]string)
    21  	return sm
    22  }
    23  

View as plain text