utils

package
v0.0.0-...-a7f6470 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Auth bool

Auth variable neglects auth layer

View Source
var PatternUrl = regexp.MustCompile("(https|http)://[-A-Za-z0-9_+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]")

PatternUrl represents http pattern

View Source
var STATICDIR string

STATICDIR defines location of all static files

View Source
var VERBOSE int

VERBOSE variable controls verbosity level of client's utilities

Functions

func CheckX509

func CheckX509()

CheckX509 function checks X509 settings

func ErrPropagate

func ErrPropagate(api string)

ErrPropagate error helper function which can be used in defer ErrPropagate()

func ErrPropagate2Channel

func ErrPropagate2Channel(api string, ch chan interface{})

ErrPropagate2Channel error helper function which can be used in goroutines as ch := make(chan interface{})

go func() {
   defer ErrPropagate2Channel(api, ch)
   someFunction()
}()

func Fetch

func Fetch(rurl string, args []byte, ch chan<- ResponseType)

Fetch data for provided URL and redirect results to given channel

func FindInList

func FindInList(a string, arr []string) bool

FindInList helper function to find item in a list

func GoDeferFunc

func GoDeferFunc(api string, f func())

GoDeferFunc helper function to run any given function in defered go routine

func Hash

func Hash(data []byte) (string, int64)

Hash implements hash function for data, it returns a hash and number of bytes

func HostIP

func HostIP() []string

HostIP provides a list of host IPs

func HttpClient

func HttpClient() *http.Client

HttpClient provides HTTP client

func InList

func InList(a string, list []string) bool

InList helper function to check item in a list

func List2Set

func List2Set(arr []string) []string

List2Set helper function to convert input list into set

func ListFiles

func ListFiles(dir string) []string

ListFiles function list files in given directory

func MapKeys

func MapKeys(rec map[string]interface{}) []string

MapKeys helper function to return keys from a map

func ParseTmpl

func ParseTmpl(tmpl string, data interface{}) string

ParseTmpl is a template parser with given data

func Response

func Response(rurl string, data []byte) []byte

Response represents final response in a form of JSON structure we use custorm representation

func SourceLine

func SourceLine() string

SourceLine returns callers, i.e. file_name:line_number

func Stack

func Stack() string

Stack helper function to return Stack

func UsedCPU

func UsedCPU() (float64, error)

UsedCPU calculates CPU usage

func UsedRAM

func UsedRAM() (float64, error)

UsedRAM gets used ram

func UserDN

func UserDN(r *http.Request) string

UserDN function parses user Distinguished Name (DN) from client's HTTP request

Types

type ResponseType

type ResponseType struct {
	Url        string // response url
	Data       []byte // response data, i.e. what we got with Body of the response
	Error      error  // http error, a non-2xx return code is not an error
	Status     string // http status string
	StatusCode int    // http status code
}

ResponseType structure is what we expect to get for our URL call. It contains a request URL, the data chunk and possible error from remote

func FetchResponse

func FetchResponse(rurl string, args []byte) ResponseType

FetchResponse fetches data for provided URL, args is a json dump of arguments

func (*ResponseType) String

func (r *ResponseType) String() string

String provides string representation for ResponseType

type UrlRequest

type UrlRequest struct {
	// contains filtered or unexported fields
}

UrlRequest structure holds details about url request's attributes

Jump to

Keyboard shortcuts

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