lib

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 24 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoolError = errors.New("Invalid boolean value")
View Source
var ErrFailedToParse = errors.New("Error in parsing filter")
View Source
var OpLookup map[string]OpType
View Source
var OpLookupStr map[OpType]string

Functions

func ApplyFilter

func ApplyFilter(filter []*FilterType, mdata map[string]interface{}) bool

func DelFromSliceString

func DelFromSliceString(s []string, nth int) (rv []string)

Remove the `nth` element from the slice `s` returning the modified slice. If `nth` is out of range then just return the input `s`

func DumpReCache

func DumpReCache()

func Exists

func Exists(name string) bool

Exists reports whether the named file or directory exists.

func ExistsGetFileInfo

func ExistsGetFileInfo(name string) (bool, os.FileInfo)

-------------------------------------------------------------------------------------------------

type FileInfo interface {
	Name() string       // base name of the file
	Size() int64        // length in bytes for regular files; system-dependent for others
	Mode() FileMode     // file mode bits
	ModTime() time.Time // modification time
	IsDir() bool        // abbreviation for Mode().IsDir()
	Sys() interface{}   // underlying data source (can return nil)
}

Exists reports whether the named file or directory exists. -------------------------------------------------------------------------------------------------

func ExistsGetUDate

func ExistsGetUDate(name string) (bool, os.FileInfo)

func ExistsIsDir

func ExistsIsDir(name string) bool

func ExistsIsExecutable

func ExistsIsExecutable(name string) bool

Check that a file exists and is an executable program - Linux/Unix/MacOS - 'x' permissions && not a directory

func ExternalIP

func ExternalIP() (rv []string, err error)

Return a list of IPs that are listend to by this system.

func FilepathAbs

func FilepathAbs(fn string) (rfn string)

func FirstName

func FirstName(ww map[string]interface{}) (rv string)

func Fopen

func Fopen(fn string, mode string) (file *os.File, err error)

func GenSHA

func GenSHA(data []byte) (s string)

func GenURL

func GenURL(www http.ResponseWriter, req *http.Request) (url string, hUrl string)

Return the full URL with http://host:port/path/path?arg=value

func GenURLFromReq

func GenURLFromReq(req *http.Request) (url string)

------------------------------------------------------------------------------------------------- Convert from a request back to a URL

func GenURLFromReqProxy

func GenURLFromReqProxy(req *http.Request, newHost string) (url string)

------------------------------------------------------------------------------------------------- Convert from a request back to a URL

func GetCTypes

func GetCTypes(www http.ResponseWriter, bod []byte) (ctypes []string)

func GetCookie

func GetCookie(name string, req *http.Request) (rv string)

cookieValue := lib.GetCookie ( "LoginAuthCookie", req ) -------------------------------------------------------------------------------------------------

func GetExtenstionBasedOnMimeType

func GetExtenstionBasedOnMimeType(mt string) (ext string)

function to get extension based on mime type

func GetFileSize

func GetFileSize(fn string) int64

GetFileSize returns the file size in bytes

func GetFilenames

func GetFilenames(dir string) (filenames, dirs []string)

------------------------------------------------------------------------------------------------- Get a list of filenames and directorys.

func GetFilenamesSorted

func GetFilenamesSorted(dir string) (filenames, dirs []string)

-------------------------------------------------------------------------------------------------

func GetIP

func GetIP(req *http.Request) (ip string)

func GetImageDimension

func GetImageDimension(imagePath string) (width int, height int)

GetImageDimension returns width, height of an immage - .png, .jpg, .gif

  • not working on .svg
  • not returning errors

Example:

h, w = GetHWFromImage ( ffile_name );

func GetIpFromReq

func GetIpFromReq(req *http.Request) (ip string, err error)

-------------------------------------------------------------------------------------------------

func GetPackageName

func GetPackageName(fnln string) (newFn, pkg string)

func GetPort

func GetPort(req *http.Request) (rv string)

func GetRemoteIP

func GetRemoteIP(req *http.Request) string

func GetUUIDAsString

func GetUUIDAsString() (rv string)

func HasHeader

func HasHeader(wr http.ResponseWriter, name string) (val string, found bool)

------------------------------------------------------------------------------------------------- func (hdlr RedirectHandlerType) ServeHTTP(www http.ResponseWriter, req *http.Request) {

func HashStrings

func HashStrings(a ...string) string

func InArray

func InArray(lookFor string, inArr []string) bool

-------------------------------------------------------------------------------------------------

func InArrayN

func InArrayN(lookFor string, inArr []string) int

-------------------------------------------------------------------------------------------------

func IntAbs

func IntAbs(n int) int

Return absolute value of integer

func IsErr

func IsErr(err error) (e error)

func IsErrFatal

func IsErrFatal(err error)

func IsHtml

func IsHtml(www http.ResponseWriter, bod []byte) bool

func IsLocalPath

func IsLocalPath(s string) bool

func IsLocalhost

func IsLocalhost(s string) bool

IsLocalhost is true when passed a localhost IP address v4 or ipv6

func IsProtocal

func IsProtocal(s string) (rv bool)

func JsonStringToArrayOfData

func JsonStringToArrayOfData(s string) (theJSON []map[string]interface{}, err error)

func JsonStringToArrayOfString

func JsonStringToArrayOfString(s string) (theJSON []string, err error)

c_parsed, err2 := lib.JsonStringToArrayOfString ( b )

func JsonStringToData

func JsonStringToData(s string) (theJSON map[string]interface{}, err error)

func JsonStringToString

func JsonStringToString(s string) (theJSON map[string]string, err error)

func LF

func LF(d ...int) string

Return the File name and Line no as a string.

func LenOfMap

func LenOfMap(ww map[string]interface{}) (rv int)

func LookupRe

func LookupRe(pattern string) (rv *regexp.Regexp)

func MatchPathInList

func MatchPathInList(path string, pathList []string) bool

xyzzy - test this Match a path in a list of paths

func MatchURLPrefix

func MatchURLPrefix(APath, Pattern string) bool

MatchURLPrefix is a week regular exprssion matcher. Only 1 patterns are supported. Valid in URL chars are: A-Z, a-z, 0-9, -, ., _, ~, :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, and = ^ for either / or EOL

func Md5sum

func Md5sum(s string) (buf string)

func ParseBool

func ParseBool(s string) (bool, error)

func PathsMatch

func PathsMatch(Paths []string, APath string) bool

----------------------------------------------------------------------------------------------------------------------------------------------------

func PathsMatchIgnore

func PathsMatchIgnore(Paths []string, APath string) bool

func PathsMatchN

func PathsMatchN(Paths []string, APath string) int

func PathsMatchPos

func PathsMatchPos(Paths []string, APath string) int

func PathsMatchRe

func PathsMatchRe(Paths []string, APath string) bool

func PathsMatchReN

func PathsMatchReN(Paths []string, APath string) int

func ReadJsonFile

func ReadJsonFile(fn string) (jdata map[string]string, err error)

func SVar

func SVar(v interface{}) string

------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------

func SVarI

func SVarI(v interface{}) string

-------------------------------------------------------------------------------------------------

func SearchForFile

func SearchForFile(root []string, fn string) (string, bool)

-------------------------------------------------------------------------------------------------

func SearchForFileSimple

func SearchForFileSimple(root []string, fn string, index []string) (x string, ok bool)

func SetMaxCPUs

func SetMaxCPUs(numCPU int)

func SetupRequestHeaders

func SetupRequestHeaders(req *http.Request, hdr []NameValue)

lib.SetupRequestHeaders(req, test.hdr)

func SetupTestCreateDirs

func SetupTestCreateDirs()

func SetupTestCreateDirsFileServe

func SetupTestCreateDirsFileServe()

func SetupTestMimicReq

func SetupTestMimicReq(req *http.Request, h string)

func Sha256

func Sha256(s string) (rv string)

func TimeZero

func TimeZero() (z time.Time)

Types

type FilterType

type FilterType struct {
	Name  string
	Value string
	Op    OpType
}

func ParseFilter

func ParseFilter(ss string) (ff *FilterType, err error)

type MimeType

type MimeType int
const (
	HtmlMimeType MimeType = iota
	CssMimeType
	JSMimeType
	PngMimeType
	JpgMimeType
	GifMimeType
	WebpMimeType
	FontMimeType
)

type NameValue

type NameValue struct {
	Name  string
	Value string
}

type OpType

type OpType int
const (
	OpEq OpType = 1
	OpNe OpType = 2
)

func (OpType) String

func (x OpType) String() string

type ProtocalType

type ProtocalType int
const (
	HTTPProtocal  ProtocalType = 1
	HTTPSProtocal ProtocalType = 2
	WSProtocal    ProtocalType = 3
	WSSProtocal   ProtocalType = 4
	FileProtocal  ProtocalType = 5
	ProxyProtocal ProtocalType = 6
)

func DetermineProtocal

func DetermineProtocal(s string) (rv ProtocalType)

Looks at the leading part of a URL to determine the protocal, HTTPProtocal is the default

func (ProtocalType) String

func (p ProtocalType) String() string

type ReCacheType

type ReCacheType struct {
	Pattern string
	Re      *regexp.Regexp
}

Jump to

Keyboard shortcuts

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