1
0
mirror of https://github.com/containous/traefik.git synced 2024-12-25 23:21:40 +03:00
traefik/testhelpers/helpers.go
2017-06-09 23:55:49 +02:00

32 lines
714 B
Go

package testhelpers
import (
"fmt"
"io"
"net/http"
"net/url"
)
// Intp returns a pointer to the given integer value.
func Intp(i int) *int {
return &i
}
// MustNewRequest creates a new http get request or panics if it can't
func MustNewRequest(method, urlStr string, body io.Reader) *http.Request {
request, err := http.NewRequest(method, urlStr, body)
if err != nil {
panic(fmt.Sprintf("failed to create HTTP %s Request for '%s': %s", method, urlStr, err))
}
return request
}
// MustParseURL parses a URL or panics if it can't
func MustParseURL(rawURL string) *url.URL {
u, err := url.Parse(rawURL)
if err != nil {
panic(fmt.Sprintf("failed to parse URL '%s': %s", rawURL, err))
}
return u
}