all: support route scoped sessions

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
Bobby DeSimone 2019-11-06 17:30:27 -08:00 committed by Bobby DeSimone
parent 83342112bb
commit d3d60d1055
53 changed files with 2092 additions and 2416 deletions

View file

@ -2,6 +2,7 @@ package httputil // import "github.com/pomerium/pomerium/internal/httputil"
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
@ -27,7 +28,7 @@ var httpClient = &http.Client{
}
// Client provides a simple helper interface to make HTTP requests
func Client(method, endpoint, userAgent string, headers map[string]string, params url.Values, response interface{}) error {
func Client(ctx context.Context, method, endpoint, userAgent string, headers map[string]string, params url.Values, response interface{}) error {
var body io.Reader
switch method {
case http.MethodPost:
@ -41,7 +42,7 @@ func Client(method, endpoint, userAgent string, headers map[string]string, param
default:
return fmt.Errorf(http.StatusText(http.StatusBadRequest))
}
req, err := http.NewRequest(method, endpoint, body)
req, err := http.NewRequestWithContext(ctx, method, endpoint, body)
if err != nil {
return err
}