rest

package
v0.0.0-...-2d73068 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 12 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsoluteURL

func AbsoluteURL(req *goa.RequestData, relative string, config configuration) string

AbsoluteURL prefixes a relative URL with absolute address If config is not nil and run in dev mode then host is replaced by "auth.openshift.io"

func AddParam

func AddParam(urlString string, paramName string, paramValue string) (string, error)

AddParam adds a parameter to URL

func AddParams

func AddParams(urlString string, params map[string]string) (string, error)

AddParams adds parameters to URL

func AddTrailingSlashToURL

func AddTrailingSlashToURL(url string) string

AddTrailingSlashToURL adds a trailing slash to the URL if it doesn't have it already If URL is an empty string the function returns an empty string too

func CloseResponse

func CloseResponse(response *http.Response)

CloseResponse reads the body and close the response. To be used to prevent file descriptor leaks.

func Host

func Host(req *goa.RequestData, config configuration) string

Host returns the host from the given request if run in prod mode or if config is nil and "auth.openshift.io" if run in dev mode

func ReadBody

func ReadBody(body io.ReadCloser) string

ReadBody reads body from a ReadCloser and returns it as a string

func ReplaceDomainPrefix

func ReplaceDomainPrefix(host string, replaceBy string) (string, error)

ReplaceDomainPrefix replaces the last name in the host by a new name. Example: api.service.domain.org -> sso.service.domain.org If replaceBy == "" then return trim the last name. Example: api.service.domain.org -> service.domain.org

func ReplaceDomainPrefixInAbsoluteURL

func ReplaceDomainPrefixInAbsoluteURL(req *goa.RequestData, replaceBy, relative string, config configuration) (string, error)

ReplaceDomainPrefixInAbsoluteURL replaces the last name in the host of the URL by a new name. Example: https://api.service.domain.org -> https://sso.service.domain.org If replaceBy == "" then return trim the last name. Example: https://api.service.domain.org -> https://service.domain.org Also prefixes a relative URL with absolute address If config is not nil and run in dev mode then "auth.openshift.io" is used as a host

func ReplaceDomainPrefixInAbsoluteURLStr

func ReplaceDomainPrefixInAbsoluteURLStr(urlStr, replaceBy, relative string) (string, error)

ReplaceDomainPrefixInAbsoluteURLStr check ReplaceDomainPrefixInAbsoluteURL. This works on url string.

func ValidateEmail

func ValidateEmail(email string) (bool, error)

ValidateEmail return true if the string is a valid email address This is a very simple validation. It just checks if there is @ and dot in the address

Types

type HTTPClientOption

type HTTPClientOption func(client *http.Client)

HTTPClientOption options passed to the HTTP Client

func WithRoundTripper

func WithRoundTripper(r http.RoundTripper) HTTPClientOption

WithRoundTripper configures the client's transport with the given round-tripper

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient defines the Do method of the http client.

type HttpClientDoer

type HttpClientDoer struct {
	HttpClient HttpClient
}

HttpClientDoer implements HttpDoer

func (*HttpClientDoer) Do

Do overrides Do method of the default goa client Doer. It's needed for mocking http clients in tests.

type HttpDoer

type HttpDoer interface {
	client.Doer
}

Doer is a wrapper interface for goa client Doer

func DefaultHttpDoer

func DefaultHttpDoer() HttpDoer

DefaultHttpDoer creates a new HttpDoer with default http client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL