Skip to content

Madh93/go-hoarder

Repository files navigation

go-hoarder

Go Version Latest tag Go Reference License

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.

Requirements

Installation

To install go-hoarder, use go get:

go get github.com/Madh93/go-hoarder

Usage

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.

Documentation

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.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bug fixes or enhancements.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Open a Pull Request.

License

This project is licensed under the MIT license.