http

package
v0.0.0-...-2374f08 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSource

type JSONSource struct {
	// contains filtered or unexported fields
}

JSONSource implements the pdk.Source interface by listening for HTTP post requests and decoding json from their bodies.

func NewJSONSource

func NewJSONSource(opts ...JSONSourceOption) (*JSONSource, error)

NewJSONSource creates a JSONSource - it takes JSONSourceOptions which modify its behavior.

func (*JSONSource) Addr

func (j *JSONSource) Addr() string

Addr gets the address that the JSONSource is listening on.

func (*JSONSource) Record

func (j *JSONSource) Record() (interface{}, error)

Record returns an unmarshaled json document as a map[string]interface. That is, the resulting interface{} can be cast to a map[string]interface{}.

func (*JSONSource) ServeHTTP

func (j *JSONSource) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for JSONSource

type JSONSourceOption

type JSONSourceOption func(j *JSONSource)

JSONSourceOption is a functional option type for JSONSource.

func WithAddr

func WithAddr(addr string) JSONSourceOption

WithAddr is an option for the JSONSource which causes it to bind to the given address.

func WithBuffer

func WithBuffer(n int) JSONSourceOption

WithBuffer is an option for JSONSource which modifies the length of the channel used to buffer received records (while they are waiting to be retrieved by a call to Record).

func WithListener

func WithListener(l net.Listener) JSONSourceOption

WithListener is an option for JSONSource which causes it to use the given listener. It will infer the address from the listener.

type Main

type Main struct {
	Bind        string   `help:"Listen for post requests on this address."`
	PilosaHosts []string `help:"List of host:port pairs for Pilosa cluster."`
	Index       string   `help:"Pilosa index to write to."`
	BatchSize   uint     `help:"Batch size for Pilosa imports."`
	Framer      pdk.DashField
	Subjecter   SubjecterOpts
	Proxy       string `help:"Bind to this address to proxy and translate requests to Pilosa"`
}

Main holds the config for the http command.

func NewMain

func NewMain() *Main

NewMain gets a new Main with default values.

func (*Main) Run

func (m *Main) Run() error

Run runs the http command.

type SubjecterOpts

type SubjecterOpts struct {
	Path []string `help:"Path to subject."`
}

SubjecterOpts are options for the Subjecter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL