Documentation ¶
Index ¶
- Constants
- func APIError(c *gin.Context, format string, args ...interface{})
- func ExecPipeWs(cmd []string, env []string, so *socketio.Socket, sid string, cmdID string, ...) error
- func Exists(path string) bool
- func GetExePath() string
- func GetUserHome() string
- func IsDir(path string) bool
- func PathNormalize(p string) string
- func ResolveEnvVar(s string) (string, error)
- type EmitExitCB
- type EmitOutputCB
- type HTTPClient
- func (c *HTTPClient) Delete(url string, out interface{}) error
- func (c *HTTPClient) Get(url string, out interface{}) error
- func (c *HTTPClient) GetClientID() string
- func (c *HTTPClient) GetLogLevel() string
- func (c *HTTPClient) HTTPDelete(url string) error
- func (c *HTTPClient) HTTPDeleteWithRes(url string) (*http.Response, error)
- func (c *HTTPClient) HTTPGet(url string, data *[]byte) error
- func (c *HTTPClient) HTTPGetWithRes(url string, data *[]byte) (*http.Response, error)
- func (c *HTTPClient) HTTPPost(url string, body string) error
- func (c *HTTPClient) HTTPPostWithRes(url string, body string) (*http.Response, error)
- func (c *HTTPClient) HTTPPut(url string, body string) error
- func (c *HTTPClient) HTTPPutWithRes(url string, body string) (*http.Response, error)
- func (c *HTTPClient) LogLevelToString(lvl int) string
- func (c *HTTPClient) Post(url string, in interface{}, out interface{}) error
- func (c *HTTPClient) Put(url string, in interface{}, out interface{}) error
- func (c *HTTPClient) ResponseToBArray(response *http.Response) []byte
- func (c *HTTPClient) SetLogLevel(lvl string) error
- type HTTPClientConfig
Constants ¶
const ( HTTPLogLevelPanic = 0 HTTPLogLevelError = 1 HTTPLogLevelWarning = 2 HTTPLogLevelInfo = 3 HTTPLogLevelDebug = 4 )
Logger levels constants
Variables ¶
This section is empty.
Functions ¶
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 GetExePath ¶ added in v0.1.2
func GetExePath() string
GetExePath returns the full path of the current executable
func GetUserHome ¶ added in v0.1.1
func GetUserHome() string
GetUserHome returns the user's home directory or empty string on error
func PathNormalize ¶
PathNormalize normalizes a linux or windows like path
func ResolveEnvVar ¶
ResolveEnvVar Resolved environment variable regarding the syntax ${MYVAR} or $MYVAR following by a slash or a backslash
Types ¶
type EmitExitCB ¶
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) Delete ¶ added in v0.1.5
func (c *HTTPClient) Delete(url string, out interface{}) error
Delete Send a Delete request to client and return directly data of body response
func (*HTTPClient) Get ¶ added in v0.1.5
func (c *HTTPClient) Get(url string, out interface{}) error
Get Send a Get request to client and return directly data of body response
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) HTTPDelete ¶ added in v0.1.4
func (c *HTTPClient) HTTPDelete(url string) error
HTTPDelete Send a DELETE request to client and return an error object
func (*HTTPClient) HTTPDeleteWithRes ¶ added in v0.1.4
func (c *HTTPClient) HTTPDeleteWithRes(url string) (*http.Response, error)
HTTPDeleteWithRes Send a DELETE request to client and return both response and error
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 ¶
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 ¶
HTTPPostWithRes Send a POST request to client and return both response and error
func (*HTTPClient) HTTPPut ¶ added in v0.1.4
func (c *HTTPClient) HTTPPut(url string, body string) error
HTTPPut Send a PUT request to client and return an error object
func (*HTTPClient) HTTPPutWithRes ¶ added in v0.1.4
HTTPPutWithRes Send a PUT request to client and return both response and error
func (*HTTPClient) LogLevelToString ¶ added in v0.1.5
func (c *HTTPClient) LogLevelToString(lvl int) string
LogLevelToString Convert an integer log level to string
func (*HTTPClient) Post ¶ added in v0.1.5
func (c *HTTPClient) Post(url string, in interface{}, out interface{}) error
Post Send a Post request to client and return directly data of body response
func (*HTTPClient) Put ¶ added in v0.1.5
func (c *HTTPClient) Put(url string, in interface{}, out interface{}) error
Put Send a Put request to client and return directly data of body response
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