Documentation ¶
Index ¶
- Constants
- func GetRemoteAddr(r *http.Request) string
- func NewJSONRequest(ctx context.Context, method, url string, body interface{}) (*http.Request, error)
- func NewQueryRequest(ctx context.Context, method, url string, queries map[string]interface{}) (*http.Request, error)
- func NewTransport(options ...func(*http.Transport)) http.RoundTripper
- func NewUploadRequest(ctx context.Context, url string, reader io.Reader, ...) (*http.Request, error)
- func SendRequest(r *http.Request) (*http.Response, error)
- func WithIdleConnsPerHost(maxIdleConsPerHost int) func(*http.Transport)
- type InternalBody
- type Response
- type UploadOptions
Constants ¶
View Source
const ( HeaderAuthorization = "Authorization" HeaderRequestID = "X-REQUEST-ID" )
Define common headers
View Source
const ( VerdictMissingAuthentication = "missing_authentication" VerdictInvalidToken = "invalid_token" VerdictInvalidParameters = "invalid_parameters" VerdictSuccess = "success" VerdictFailure = "failure" VerdictNotFound = "not_found" VerdictDuplicate = "duplicate" VerdictLimitExceeded = "limit_exceeded" VerdictExpiredData = "expired_data" VerdictPermissionDenied = "permission_denied" )
Define common verdicts for common cases Each service can define its own verdicts
View Source
const (
TokenTypeBearer = "Bearer"
)
Defines common token type
Variables ¶
This section is empty.
Functions ¶
func NewJSONRequest ¶
func NewJSONRequest(ctx context.Context, method, url string, body interface{}) (*http.Request, error)
NewJSONRequest creates new request with JSON body
func NewQueryRequest ¶
func NewQueryRequest(ctx context.Context, method, url string, queries map[string]interface{}) (*http.Request, error)
NewQueryRequest creates request with query strings
func NewTransport ¶
func NewTransport(options ...func(*http.Transport)) http.RoundTripper
func NewUploadRequest ¶
func NewUploadRequest(ctx context.Context, url string, reader io.Reader, modifiers ...func(*UploadOptions)) (*http.Request, error)
NewUploadRequest create a new http upload file request
func SendRequest ¶
SendRequest sends general request to a URL and returns HTTP response
func WithIdleConnsPerHost ¶
Types ¶
type InternalBody ¶
type InternalBody[R any] struct { Verdict string `json:"verdict"` Message string `json:"message"` Time time.Time `json:"time"` Data R `json:"data"` }
InternalBody defines struct for internal response body This is for communicate with internal services
Click to show internal directories.
Click to hide internal directories.