Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

guardian360/go-lighthouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-lighthouse

Go Reference


⚠️🚧 Work in Progress 🚧⚠️

This project is still under active development. APIs and functionality may change, and certain features may not yet be fully implemented.

Not recommended for production use.


A Go client library for interacting with the Lighthouse API.

📖 Overview

The go-lighthouse library provides a Go client for interacting with Lighthouse API endpoints. It supports OAuth authentication, request handling, and API versioning.

🚀 Installation

go get github.com/guardian360/go-lighthouse

🎯 Usage

Creating a Client

To interact with the Lighthouse API, you need to create a client using the client.New function. You can configure the client with the base URL. Next, you can create an API instance using the api.New function.

package main

import (
    "fmt"
    "os"

    api "github.com/guardian360/go-lighthouse/api/v2"
    "github.com/guardian360/go-lighthouse/client"
)

func main() {
    cfg := client.Config{
        BaseURL: "https://lighthouse.guardian360.nl",
    }
    clt := client.New(cfg)
    lighthouse := api.New(clt)

    response, err := lighthouse.Health().Get()
    if err != nil {
        fmt.Println("Error fetching health:", err)
        os.Exit(1)
    }

    fmt.Printf("Lighthouse API response: %+v\n", response)
}

Authenticating with OAuth

Most Lighthouse API endpoints require OAuth authentication. The go-lighthouse library supports OAuth authentication using the client credentials grant. You can create an OAuth client using the Lighthouse portal to obtain a client ID and client secret.

package main

import (
    "fmt"
    "os"

    api "github.com/guardian360/go-lighthouse/api/v2"
    "github.com/guardian360/go-lighthouse/client"
)

func main() {
    cfg := client.Config{
        BaseURL: "https://lighthouse.guardian360.nl",
    }
    clt := client.New(cfg).WithOAuth(&client.ClientCredentialsGrant{
        TokenURL: cfg.BaseURL + "/oauth/token",
        ClientID: "client_id",
        ClientSecret: "client_secret",
    })
    lighthouse := api.New(clt)

    resp, err := lighthouse.Probes().Get()
    if err != nil {
        fmt.Println("Error fetching probes:", err)
        os.Exit(1)
    }

    fmt.Printf("Lighthouse API response: %+v\n", resp)
}

🛠 Contributing

Contributions are welcome! For feature requests, bug reports, or questions, please open an issue. For code contributions, please open a pull request.

📚 Documentation

For more information, please refer to the Go reference documentation.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Lighthouse API client written in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages