GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - deploymenttheory/go-api-http-client: A modular Go http client used by for interacting with Modern Workplace tooling api's

BranchesTags
Open more actions menu

Latest commit

 

History

1,049 Commits
1,049 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.pipelines
.pipelines
 
 
concurrency
concurrency
 
 
docs
docs
 
 
httpclient
httpclient
 
 
ratehandler
ratehandler
 
 
redirect_policy_template
redirect_policy_template
 
 
response
response
 
 
test
test
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 

Repository files navigation

Go API HTTP Client

This Go module offers a sophisticated HTTP client designed for seamless API interactions, with a strong emphasis on concurrency management, robust error handling, extensive logging, and adaptive rate limiting. It's particularly suitable for applications requiring high-throughput API interactions with complex authentication and operational resilience.

This client is designed to be used with targetted SDK's and terraform providers only. As such the http client cannot be used without a supporting SDK and associated api integration plugin go-api-http-client-integrations.

The plugin is required to provide the necessary API-specific handlers and configuration to the HTTP client. The plugin approach is designed to provide a consistent interface for interacting with various APIs, including Microsoft Graph, Jamf Pro, and others. It is easily extensible to support additional APIs and highly configurable to meet specific API requirements. It achieves this through using a modular design, with a core HTTP client and API-specific handlers that encapsulate the unique requirements of each API supported. Conseqently the client provides core common HTTP client functionality, such as rate limiting, logging, concurrency and responses while the plugin provides the API-specific logic, such as encoding and decoding requests, managing authentication endpoints, and handling API-specific logic.

HTTP Client Features

  • Comprehensive Authentication Support: Robust support for various authentication schemes, including OAuth and Bearer Token, with built-in token management and validation.
  • Advanced Concurrency Management: An intelligent Concurrency Manager dynamically adjusts concurrent request limits to optimize throughput and adhere to API rate limits.
  • Structured Error Handling: Clear and actionable error reporting facilitates troubleshooting and improves reliability.
  • Performance Monitoring: Detailed performance metrics tracking provides insights into API interaction efficiency and optimization opportunities.
  • Configurable Logging: Extensive logging capabilities with customizable levels and formats aid in debugging and operational monitoring.
  • Adaptive Rate Limiting: Dynamic rate limiting automatically adjusts request rates in response to API server feedback.
  • Flexible Configuration: Extensive customization of HTTP client behavior to meet specific API requirements, including custom timeouts, retry strategies, header management, and more.
  • Header Management: Easy and efficient management of HTTP request headers, ensuring compliance with API requirements.
  • Enhanced Logging with Zap: Utilizes Uber's zap library for structured, high-performance logging, offering levels from Debug to Fatal, including structured context and dynamic adjustment based on the environment.
  • API Handler Interface: Provides a flexible and extensible way to interact with different APIs, including encoding and decoding requests and responses, managing authentication endpoints, and handling API-specific logic.
  • Configuration via JSON or Environment Variables: The Go API HTTP Client supports configuration via JSON files or environment variables, providing flexibility in defining authentication credentials, API endpoints, logging settings, and other parameters.

Getting Started

This SDK requires an existing Go environment to build and run. If you do not have Go installed, you can download and install it from the official Go website.

Reverse-proxy headers

Use one RequestHeaderConfig for the integration's token bootstrap client and the API client. This supports a proxy requiring Basic credentials in Authorization while the integration's automatically refreshed bearer token is sent in a different header.

headers := httpclient.RequestHeaderConfig{
    BearerTokenHeader: "X-Jamf-Authorization",
    CustomHeaders: map[string]string{
        "Authorization": proxyBasicAuthorization,
    },
}
bootstrap, err := headers.HTTPClient(http.Client{Timeout: 60 * time.Second}, baseURL)
if err != nil {
    return err
}
// Pass bootstrap to the API integration's authentication constructor.
client, err := (&httpclient.ClientConfig{
    Integration: integration,
    RequestHeaders: headers,
    HideSensitiveData: true,
}).Build()

Bearer tokens are relocated for each request, so token refresh remains owned by the integration. The default token header is Authorization. Static headers cannot overwrite the managed token header; invalid or duplicate header names and invalid values are rejected without printing the values.

The policy clones requests and configuration headers, preserves the supplied transport and timeout, and only applies headers to the configured origin. Configured clients reject cross-origin redirects to prevent forwarding proxy credentials or custom token headers. Ordinary clients without header options keep their existing behavior. With sensitive logging hidden, raw responses containing request headers are not logged.

SDK Support

This http client is used in conjuction with the following SDKs:

  • go-api-sdk-m365

  • go-api-sdk-jamfpro

Reporting Issues and Feedback

Issues and Bugs

If you find any bugs, please file an issue in the [GitHub Issues][GitHubIssues] page. Please fill out the provided template with the appropriate information.

If you are taking the time to mention a problem, even a seemingly minor one, it is greatly appreciated, and a totally valid contribution to this project. Thank you!

Feedback

Contributions are welcome to make this HTTP client even better! Feel free to fork the repository, make your improvements, and submit a pull request. For major changes or new features, please file an issue or feature request in the [GitHub Issues][GitHubIssues] page to discuss what you would like to change.

Contribution

If you would like to become an active contributor to this repository or project, please follow the instructions provided in [CONTRIBUTING.md][Contributing].

About

A modular Go http client used by for interacting with Modern Workplace tooling api's

Topics

api-clienteucgolanghttp-clientjamfjamf-pro-apimsgraphapi

Resources

Readme
MPL-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

Generated from deploymenttheory/Template
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.