jmervine / splunking

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

Home Page:https://godoc.org/github.com/jmervine/splunking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Splunk Request

Build Status GoDoc

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

Usage

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)
}

About

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

https://godoc.org/github.com/jmervine/splunking


Languages

Language:Go 99.3%Language:Makefile 0.7%