Documentation ¶
Overview ¶
Description: This package provides a set of functions to create HTTP requests with a JSON body and a Bearer token.
Index ¶
- func CreateJSONHTTPRequestNoBearer(method, url, customTokenKey, idToken string, body io.Reader) (*http.Request, error)
- func CreateJSONHTTPRequestWithBearer(method, url, customTokenKey, idToken string, body io.Reader) (*http.Request, error)
- func CreateRequestBody(data interface{}) (io.Reader, error)
- func DoRequest(ctx context.Context, client *http.Client, r *http.Request) (*http.Response, error)
- func ExtractHeaders(r *http.Request, headerKeys ...string) map[string]string
- func ForwardHeaders(incomingRequest, outgoingRequest *http.Request, headerKeys ...string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateJSONHTTPRequestNoBearer ¶
func CreateJSONHTTPRequestNoBearer(method, url, customTokenKey, idToken string, body io.Reader) (*http.Request, error)
CreateJSONHTTPRequestNoBearer creates an HTTP request with the given method, URL, idToken and body.
It sets the customTokenKey header to the provided idToken.
It also sets the Content-Type header to "application/json".
It returns the created *http.Request and any error encountered.
func CreateJSONHTTPRequestWithBearer ¶
func CreateJSONHTTPRequestWithBearer(method, url, customTokenKey, idToken string, body io.Reader) (*http.Request, error)
CreateJSONHTTPRequestWithBearer creates an HTTP request with the given method, URL, idToken and body.
It sets the Authorization header to "Bearer " followed by the provided idToken.
It also sets the Content-Type header to "application/json".
It returns the created *http.Request and any error encountered.
func CreateRequestBody ¶ added in v1.13.8
CreateRequestBody creates a request body from the given data.
func DoRequest ¶ added in v1.13.7
DoRequest performs an HTTP request.
It blocks until a response is received or the context is done.
A context with a timeout should be used to prevent the method from blocking indefinitely.
func ExtractHeaders ¶ added in v1.13.9
ExtractHeaders extracts the headers from an HTTP request and format them as a map[string]string.
func ForwardHeaders ¶ added in v1.13.6
ForwardHeaders forwards headers from an incoming request to an outgoing request.
Types ¶
This section is empty.