Documentation
¶
Index ¶
- Constants
- func AddAuthHeaders(ctx context.Context, r *http.Request, serviceToken string)
- func AddDeprecatedHeader(r *http.Request, token string)
- func AddDownloadServiceTokenHeader(r *http.Request, serviceToken string)
- func AddRequestIdHeader(r *http.Request, token string)
- func AddServiceTokenHeader(r *http.Request, serviceToken string)
- func AddUserHeader(r *http.Request, user string)
- func Caller(ctx context.Context) string
- func GetRequestId(ctx context.Context) string
- func IsCallerPresent(ctx context.Context) bool
- func IsFlorenceIdentityPresent(ctx context.Context) bool
- func IsUserPresent(ctx context.Context) bool
- func NewRequestID(size int) string
- func SetCaller(ctx context.Context, caller string) context.Context
- func SetFlorenceHeader(ctx context.Context, r *http.Request)
- func SetFlorenceIdentity(ctx context.Context, user string) context.Context
- func SetUser(ctx context.Context, user string) context.Context
- func User(ctx context.Context) string
- func WithRequestId(ctx context.Context, correlationId string) context.Context
- type APIClient
- type CheckRequester
- type ContextKey
- type IdentityResponse
- type ONSError
- type Params
- type RCHTTPClienter
Constants ¶
const ( FlorenceHeaderKey = "X-Florence-Token" DownloadServiceHeaderKey = "X-Download-Service-Token" FlorenceCookieKey = "access_token" AuthHeaderKey = "Authorization" UserHeaderKey = "User-Identity" RequestHeaderKey = "X-Request-Id" DeprecatedAuthHeader = "Internal-Token" LegacyUser = "legacyUser" BearerPrefix = "Bearer " UserIdentityKey = ContextKey("User-Identity") CallerIdentityKey = ContextKey("Caller-Identity") RequestIdKey = ContextKey("request-id") FlorenceIdentityKey = ContextKey("florence-id") )
A list of common constants used across go-ns packages
Variables ¶
This section is empty.
Functions ¶
func AddAuthHeaders ¶
AddAuthHeaders sets authentication headers for request
func AddDeprecatedHeader ¶
AddDeprecatedHeader sets the deprecated header on the given request
func AddDownloadServiceTokenHeader ¶
AddDownloadServiceTokenHeader sets the given download service token on the given request
func AddRequestIdHeader ¶
AddRequestIdHeader add header for given correlation ID
func AddServiceTokenHeader ¶
AddServiceTokenHeader sets the given service token on the given request
func AddUserHeader ¶
AddUserHeader sets the given user ID on the given request
func GetRequestId ¶
GetRequestId gets the correlation id on the context
func IsCallerPresent ¶
IsCallerPresent determines if an identity is present on the given context.
func IsFlorenceIdentityPresent ¶
IsFlorenceIdentityPresent determines if a florence identity is present on the given context
func IsUserPresent ¶
IsUserPresent determines if a user identity is present on the given context
func NewRequestID ¶
NewRequestID generates a random string of requested length
func SetFlorenceHeader ¶
SetFlorenceHeader sets a florence Header if the corresponding Identity key is in context
func SetFlorenceIdentity ¶
SetFlorenceIdentity sets the florence identity for authentication
Types ¶
type APIClient ¶
type APIClient struct { BaseURL string AuthToken string HTTPClient RCHTTPClienter Lock sync.RWMutex }
APIClient represents a common structure for any api client
type CheckRequester ¶
CheckRequester is an interface to allow mocking of auth.CheckRequest
type IdentityResponse ¶
type IdentityResponse struct {
Identifier string `json:"identifier"`
}
IdentityResponse represents the response from the identity service
type ONSError ¶
ONSError encapsulates an error with additional parameters
func NewONSError ¶
NewONSError creates a new ONS error
func (*ONSError) AddParameter ¶
AddParameter method creates or overwrites parameters attatched to an ONSError
type RCHTTPClienter ¶
type RCHTTPClienter interface { SetAuthToken(token string) SetDownloadServiceToken(token string) SetTimeout(timeout time.Duration) SetMaxRetries(int) GetMaxRetries() int Get(ctx context.Context, url string) (*http.Response, error) Head(ctx context.Context, url string) (*http.Response, error) Post(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error) Put(ctx context.Context, url string, contentType string, body io.Reader) (*http.Response, error) PostForm(ctx context.Context, uri string, data url.Values) (*http.Response, error) Do(ctx context.Context, req *http.Request) (*http.Response, error) }
RCHTTPClienter provides an interface for methods on an HTTP Client
Directories
¶
Path | Synopsis |
---|---|
Package mock_common is a generated GoMock package.
|
Package mock_common is a generated GoMock package. |