common

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPLogLevelPanic   = 0
	HTTPLogLevelError   = 1
	HTTPLogLevelWarning = 2
	HTTPLogLevelInfo    = 3
	HTTPLogLevelDebug   = 4
)

Variables

This section is empty.

Functions

func APIError

func APIError(c *gin.Context, format string, args ...interface{})

APIError returns an uniform json formatted error

func ExecPipeWs

func ExecPipeWs(cmd []string, env []string, so *socketio.Socket, sid string, cmdID string,
	cmdExecTimeout int, log *logrus.Logger, eoCB EmitOutputCB, eeCB EmitExitCB, data *map[string]interface{}) error

ExecPipeWs executes a command and redirect stdout/stderr into a WebSocket

func Exists

func Exists(path string) bool

Exists returns whether the given file or directory exists or not

func GetUserHome added in v0.1.1

func GetUserHome() string

GetUserHome returns the user's home directory or empty string on error

func IsDir added in v0.0.2

func IsDir(path string) bool

IsDir returns true when the given path is a directory

func PathNormalize

func PathNormalize(p string) string

PathNormalize normalizes a linux or windows like path

func ResolveEnvVar

func ResolveEnvVar(s string) (string, error)

ResolveEnvVar Resolved environment variable regarding the syntax ${MYVAR} or $MYVAR following by a slash or a backslash

Types

type EmitExitCB

type EmitExitCB func(sid string, cmdID string, code int, err error, data *map[string]interface{})

EmitExitCB is the function callback used to emit exit proc code

type EmitOutputCB

type EmitOutputCB func(sid string, cmdID string, stdout, stderr string, data *map[string]interface{})

EmitOutputCB is the function callback used to emit data

type HTTPClient

type HTTPClient struct {
	LoggerOut    io.Writer
	LoggerLevel  int
	LoggerPrefix string
	// contains filtered or unexported fields
}

HTTPClient .

func HTTPNewClient

func HTTPNewClient(baseURL string, cfg HTTPClientConfig) (*HTTPClient, error)

HTTPNewClient creates a new HTTP client to deal with Syncthing

func (*HTTPClient) GetClientID

func (c *HTTPClient) GetClientID() string

GetClientID returns the id

func (*HTTPClient) GetLogLevel added in v0.1.0

func (c *HTTPClient) GetLogLevel() string

GetLogLevel Get a readable string representing the log level

func (*HTTPClient) HTTPGet

func (c *HTTPClient) HTTPGet(url string, data *[]byte) error

HTTPGet Send a Get request to client and return an error object

func (*HTTPClient) HTTPGetWithRes

func (c *HTTPClient) HTTPGetWithRes(url string, data *[]byte) (*http.Response, error)

HTTPGetWithRes Send a Get request to client and return both response and error

func (*HTTPClient) HTTPPost

func (c *HTTPClient) HTTPPost(url string, body string) error

HTTPPost Send a POST request to client and return an error object

func (*HTTPClient) HTTPPostWithRes

func (c *HTTPClient) HTTPPostWithRes(url string, body string) (*http.Response, error)

HTTPPostWithRes Send a POST request to client and return both response and error

func (*HTTPClient) ResponseToBArray added in v0.0.2

func (c *HTTPClient) ResponseToBArray(response *http.Response) []byte

ResponseToBArray converts an Http response to a byte array

func (*HTTPClient) SetLogLevel added in v0.1.0

func (c *HTTPClient) SetLogLevel(lvl string) error

SetLogLevel set the log level from a readable string

type HTTPClientConfig

type HTTPClientConfig struct {
	URLPrefix           string
	HeaderAPIKeyName    string
	Apikey              string
	HeaderClientKeyName string
	CsrfDisable         bool
}

HTTPClientConfig is used to config HTTPClient

Directories

Path Synopsis
Package eows is used to Execute commands Over WebSocket Package eows is used to Execute commands Over WebSocket
Package eows is used to Execute commands Over WebSocket Package eows is used to Execute commands Over WebSocket

Jump to

Keyboard shortcuts

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