Documentation ¶
Overview ¶
Package persistentconn implements the persistent script protocol that splunk core uses to communicate with app's persistent REST endpoint. This package handles basic routing and request/response handling.
Index ¶
Constants ¶
const ( // OPCODE_REQUEST_INIT is a bit mask that's used to verify if request is the first request OPCODE_REQUEST_INIT = 0x01 // OPCODE_REQUEST_BLOCK is a bit mask that's used to verify if request contains input block OPCODE_REQUEST_BLOCK = 0x02 // OPCODE_REQUEST_END is a bit mask that's used to verify if request is the end OPCODE_REQUEST_END = 0x04 // OPCODE_REQUEST_ALLOW_STREAM is a bit mask that's used to verify if request indicates streaming handler is allowed OPCODE_REQUEST_ALLOW_STREAM = 0x08 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
Handler is a handler function that takes a persistentconn request and returns a response or error if error is returned, the server will return a 500 (Internal Server Error) response with the returned error's message as the response body
type Request ¶
type Request struct { OutputMode string `json:"output_mode"` Headers map[string]string `json:"headers"` Method string `json:"method"` Namespace struct { App string `json:"app"` User string `json:"user"` } `json:"namespace"` Session struct { User string `json:"user"` Authtoken string `json:"authtoken"` } `json:"session"` Query map[string]string `json:"query"` Form map[string]string `json:"form,omitempty"` Payload string `json:"payload,omitempty"` Path string `json:"path"` Params map[string]string `json:"params,omitempty"` // contains filtered or unexported fields }
Request contains information of an incoming request
type RequestPacket ¶
type RequestPacket struct {
// contains filtered or unexported fields
}
RequestPacket object representing a received packet
func ReadPacket ¶
func ReadPacket(reader io.Reader) (*RequestPacket, error)
ReadPacket creates a packet based on input and communication protocol set by splunkd.
type Response ¶
type Response struct { StatusCode int `json:"status"` Body string `json:"payload"` // contains filtered or unexported fields }
Response represents the response sent back to the client
func NoMatchingHandler ¶
NoMatchingHandler is the default handler returned when no matching path is found from a request
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the persistentconn server that handles request and writes response back to the client
func (*Server) Handle ¶
Handle registers a handler function for a given path (or path pattern). A path pattern is in the format of "<component>/:<param_1>/<component>/..." and a path component starting with ":" indicates it's a parameter which will be inferred from the actual path in the request E.g. if the registered path pattern is "entity/:name/data" and the path in the request is "entity/hello/data", then the key-value pair {"name": "hello"} will be stored in the request's params which can be later referenced inside of the handler.