an updated and hopefully faster version of the ST Toolbox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
575 B

package api
import (
"io"
"net/http"
)
// AuthenticatedRequest wraps an http.Request with the session cookie
func AuthenticatedRequest(session *Session, method, url string, body io.Reader) (*http.Request, error) {
req, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}
req.Header.Set("Cookie", session.Cookie)
return req, nil
}
// DoAuthenticatedRequest performs an authenticated request and returns the response
func DoAuthenticatedRequest(session *Session, req *http.Request) (*http.Response, error) {
return session.Client.Do(req)
}