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.
The go-lighthouse library provides a Go client for interacting with
Lighthouse API endpoints. It supports OAuth authentication, request handling,
and API versioning.
go get github.com/guardian360/go-lighthouseTo 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)
}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)
}Contributions are welcome! For feature requests, bug reports, or questions, please open an issue. For code contributions, please open a pull request.
For more information, please refer to the Go reference documentation.
This project is licensed under the MIT License - see the LICENSE file for details.