Documentation

Index

Constants

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

    Logger levels constants

    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 Exists

      func Exists(path string) bool

        Exists returns whether the given file or directory exists or not

        func GetExePath

        func GetExePath() string

          GetExePath returns the full path of the current executable

          func GetUserHome

          func GetUserHome() string

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

            func IsDir

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

                      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

                        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

                            func (c *HTTPClient) GetLogLevel() string

                              GetLogLevel Get a readable string representing the log level

                              func (*HTTPClient) HTTPDelete

                              func (c *HTTPClient) HTTPDelete(url string) error

                                HTTPDelete Send a DELETE request to client and return an error object

                                func (*HTTPClient) HTTPDeleteWithRes

                                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

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

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

                                            HTTPPut Send a PUT request to client and return an error object

                                            func (*HTTPClient) HTTPPutWithRes

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

                                              HTTPPutWithRes Send a PUT request to client and return both response and error

                                              func (*HTTPClient) LogLevelToString

                                              func (c *HTTPClient) LogLevelToString(lvl int) string

                                                LogLevelToString Convert an integer log level to string

                                                func (*HTTPClient) Post

                                                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

                                                  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

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

                                                      ResponseToBArray converts an Http response to a byte array

                                                      func (*HTTPClient) SetLogLevel

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

                                                        SetLogLevel set the log level from a readable string

                                                        type HTTPClientConfig

                                                        type HTTPClientConfig struct {
                                                        	URLPrefix           string
                                                        	ContentType         string
                                                        	HeaderAPIKeyName    string
                                                        	Apikey              string
                                                        	HeaderClientKeyName string
                                                        	CsrfDisable         bool
                                                        	LogOut              io.Writer
                                                        	LogLevel            int
                                                        	LogPrefix           string
                                                        }

                                                          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