httputils

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthorizationHeader

func GetAuthorizationHeader(bearerToken string) map[string]string

func GetAuthorizationHeaderWithContentType

func GetAuthorizationHeaderWithContentType(bearerToken string) map[string]string

func UrlBuilder

func UrlBuilder(url, endpoint string) string

UrlBuilder constructs a complete URL by combining a base URL and an endpoint. It ensures that the base URL does not end with a trailing slash ('/') before concatenating it with the endpoint. This prevents the creation of URLs with double slashes (e.g., "http://10.1.2.3//api/v1/users").

Parameters:

url: The base URL (e.g., "http://10.1.2.3").
endpoint: The endpoint to append to the base URL (e.g., "/users", "/products/123").

Returns:

A complete URL string.

Types

type CdiHTTPClient

type CdiHTTPClient interface {
	Post(payload []byte, endpoint string, queryParams map[string]string, responseAddress any, headers map[string]string) (int, error)
	Put(payload []byte, endpoint string, queryParams map[string]string, responseAddress any, headers map[string]string) (int, error)
	Delete(endpoint string, queryParams map[string]string, responseAddress any, headers map[string]string) (int, error)
	Get(endpoint string, queryParams map[string]string, responseAddress any, headers map[string]string) (int, error)
}

type StandardCdiHTTPClient

type StandardCdiHTTPClient struct {
	BaseURI string
	Client  *http.Client
}

func NewStandardCdiHTTPClient

func NewStandardCdiHTTPClient(baseURI string) *StandardCdiHTTPClient

func (*StandardCdiHTTPClient) Delete

func (c *StandardCdiHTTPClient) Delete(endpoint string, queryParams map[string]string, responseAddress any, headers map[string]string) (int, error)

func (*StandardCdiHTTPClient) Get

func (c *StandardCdiHTTPClient) Get(endpoint string, queryParams map[string]string, responseAddress any, headers map[string]string) (int, error)

func (*StandardCdiHTTPClient) Post

func (c *StandardCdiHTTPClient) Post(payload []byte, endpoint string, queryParams map[string]string, responseAddress any, headers map[string]string) (int, error)

func (*StandardCdiHTTPClient) Put

func (c *StandardCdiHTTPClient) Put(payload []byte, endpoint string, queryParams map[string]string, responseAddress any, headers map[string]string) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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