Go client library for Hoarder.
The go-hoarder
client is auto-generated using the
oapi-codegen
tool, which allows convert Hoarder OpenAPI specification to Go code.
To install go-hoarder
, use go get
:
go get github.com/Madh93/go-hoarder
Here is a basic example of how to use the go-hoarder
library:
package main
import (
"context"
"fmt"
"log"
"net/http"
"github.com/Madh93/go-hoarder"
)
func main() {
// Basic configuration
apiUrl := "https://<YOUR_HOARDER_HOSTNAME>/api/v1" // Replace this with your API URL
apiKey := "<YOUR_HOARDER_API_KEY>" // Replace this with your actual token
// Set up Bearer authentication
auth := func(ctx context.Context, req *http.Request) error {
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
return nil
}
// Create the Hoarder client
client, err := hoarder.NewClient(apiUrl, hoarder.WithRequestEditorFn(auth))
if err != nil {
log.Fatalf("Error creating client: %v", err)
}
log.Printf("Hello world from %s", client.Server)
}
For more code examples, check out the examples directory.
For detailed usage and API documentation, refer to the GoDoc.
Additionally, it's recommended to check out the latest Hoarder API documentation for more information.
Contributions are welcome! Please open an issue or submit a pull request for any bug fixes or enhancements.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
This project is licensed under the MIT license.