An open API service indexing awesome lists of open source software.

https://github.com/jmervine/splunking

Low level lib to create an http Request object for connecting to Splunk.
https://github.com/jmervine/splunking

api authentication golang http splunk

Last synced: 4 months ago
JSON representation

Low level lib to create an http Request object for connecting to Splunk.

Awesome Lists containing this project

README

          

# Splunk Request

[![Build Status](https://travis-ci.org/jmervine/splunking.svg?branch=master)](https://travis-ci.org/jmervine/splunking) [![GoDoc](https://godoc.org/github.com/jmervine/splunking?status.svg)](https://godoc.org/github.com/jmervine/splunking)

Low level lib to create an http Request object for connecting to Splunk.

### Usage

```go
import (
"fmt"

"github.com/jmervine/splunking"
)

func main() {
// Load configs from environment
// SPLUNK_USERNAME=username
// SPLUNK_PASSWORD=password
// SPLUNK_HOST=splunk.example.com
// SPLUNK_PORT=8089 // default
// SPLUNK_PROTO=https // default
// SPLUNK_OUTPUT_TYPE=json // default
client, err := splunking.Init()
if err != nil {
panic(err)
}

// Or load from URL - same defaults as above apply
client, err = splunking.InitURL("https://username:password@splunk.example.com:8089?output_type=json")
if err != nil {
panic(err)
}

// Basic request
resp, err := client.Get("/api/path", nil)
if err != nil {
panic(err)
}

fmt.Printf("%+v\n", resp)

// Advanced request handling
req, err := client.Request("GET", "/api/path", nil)
if err != nil {
panic(err)
}

// ... do stuff with request

resp, err = client.Submit(req)
if err != nil {
panic(err)
}

fmt.Printf("%+v\n", resp)
}
```