common

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

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

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

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

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

Jump to

Keyboard shortcuts

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