library

package
v0.0.0-...-d885e2b Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*AdminAL used as admin access level*/
	AdminAL = 10
	/*UserAL used as user access level*/
	UserAL = 1
)

Variables

View Source
var DB *dbx.DB

DB used as object to communicate with sqlite

Functions

func Auth

func Auth(secret string) gin.HandlerFunc

Auth used for check JWT token

func Connect

func Connect()

Connect used for connecting to sqlite

func Copy

func Copy(toValue interface{}, fromValue interface{}) (err error)

Copy copy things

func CreateHash

func CreateHash(input string) string

CreateHash used for created hash from string

func Domain

func Domain(input string) string

Domain used for get naked domain from request hostname

func DownloadFile

func DownloadFile(url, path string) error

DownloadFile used for download file

func GenerateToken

func GenerateToken(payload map[string]interface{}, expireHour time.Duration, issuer string) (string, error)

GenerateToken used for generate JWT token

func GetClaims

func GetClaims(tokenString string) (jwt.MapClaims, error)

GetClaims used for extract JWT token payload

func GetJSON

func GetJSON(url string, target interface{}) error

GetJSON used for get json from remote

func Jsonify

func Jsonify(jsonString string) ([]map[string]interface{}, error)

Jsonify used for convert json string to slice map string interface

func RBAC

func RBAC(accessLevel int) gin.HandlerFunc

RBAC used for checking user role

func Restart

func Restart()

Restart used for restart system

func SearchFile

func SearchFile(pathS, fileName, ext string) []string

SearchFile used for search file on directory

func SendMail

func SendMail(body, subject string, dest, data map[string]string)

SendMail used for create layout and send it as email

func UniqueInterface

func UniqueInterface(list *[]interface{})

UniqueInterface used for remove duplicate from slice of interface

func Unzip

func Unzip(src, dest string) error

Unzip used for unzip file

Types

type ArchiveWriteFunc

type ArchiveWriteFunc func(info os.FileInfo, file io.Reader, entryName string) (err error)

ArchiveWriteFunc is the closure used by an archive's AddAll method to actually put a file into an archive Note that for directory entries, this func will be called with a nil 'file' param

type Archivex

type Archivex interface {
	Create(name string) error
	Add(name string, file []byte) error
	AddFile(name string) error
	AddAll(dir string, includeCurrentFolder bool) error
	Close() error
}

Archivex used as archiever object

type NullBool

type NullBool struct {
	sql.NullBool
}

NullBool is a type that can be null or a bool

func (NullBool) MarshalJSON

func (n NullBool) MarshalJSON() ([]byte, error)

MarshalJSON correctly serializes a NullBool to JSON

func (*NullBool) UnmarshalJSON

func (n *NullBool) UnmarshalJSON(b []byte) error

UnmarshalJSON correctly deserializes a NullBool from JSON

type NullFloat64

type NullFloat64 struct {
	sql.NullFloat64
}

NullFloat64 is a type that can be null or a float64

func (NullFloat64) MarshalJSON

func (n NullFloat64) MarshalJSON() ([]byte, error)

MarshalJSON correctly serializes a NullFloat64 to JSON

func (*NullFloat64) UnmarshalJSON

func (n *NullFloat64) UnmarshalJSON(b []byte) error

UnmarshalJSON correctly deserializes a NullFloat64 from JSON

type NullInt64

type NullInt64 struct {
	sql.NullInt64
}

NullInt64 is a type that can be null or an int

func (NullInt64) MarshalJSON

func (n NullInt64) MarshalJSON() ([]byte, error)

MarshalJSON correctly serializes a NullInt64 to JSON

func (*NullInt64) UnmarshalJSON

func (n *NullInt64) UnmarshalJSON(b []byte) error

UnmarshalJSON correctly deserializes a NullInt64 from JSON

type NullString

type NullString struct {
	sql.NullString
}

NullString is a type that can be null or a string

func (NullString) MarshalJSON

func (n NullString) MarshalJSON() ([]byte, error)

MarshalJSON correctly serializes a NullString to JSON

func (*NullString) UnmarshalJSON

func (n *NullString) UnmarshalJSON(b []byte) error

UnmarshalJSON correctly deserializes a NullString from JSON

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool
}

NullTime is a type that can be null or a time

func (NullTime) MarshalJSON

func (n NullTime) MarshalJSON() ([]byte, error)

MarshalJSON correctly serializes a NullTime to JSON

func (*NullTime) Scan

func (n *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*NullTime) UnmarshalJSON

func (n *NullTime) UnmarshalJSON(b []byte) error

UnmarshalJSON correctly deserializes a NullTime from JSON

type Payload

type Payload struct {
	Iat          int    `json:"iat"`
	Exp          int    `json:"exp"`
	Iss          string `json:"iss"`
	Sub          string `json:"sub"`
	ID           int    `json:"id"`
	Name         string `json:"name"`
	EmailAddress string `json:"email_address"`
	LastLoggedIn int    `json:"last_logged_in"`
	AccessLevel  int    `json:"access_level"`
}

Payload used for encode/decode token

func Extract

func Extract(token string) (result Payload, err error)

Extract used for extract token to payload

type ZipFile

type ZipFile struct {
	Writer *zip.Writer
	Name   string
	// contains filtered or unexported fields
}

ZipFile implement *zip.Writer

func (*ZipFile) Add

func (z *ZipFile) Add(name string, file []byte) error

Add add byte in archive zip

func (*ZipFile) AddAll

func (z *ZipFile) AddAll(dir string, includeCurrentFolder bool) error

AddAll adds all files from dir in archive, recursively. Directories receive a zero-size entry in the archive, with a trailing slash in the header name, and no compression

func (*ZipFile) AddFile

func (z *ZipFile) AddFile(name string) error

AddFile add file from dir in archive

func (*ZipFile) AddFileWithName

func (z *ZipFile) AddFileWithName(name string, filepath string) error

AddFileWithName add a file to zip with a name

func (*ZipFile) Close

func (z *ZipFile) Close() error

Close close the zip file

func (*ZipFile) Create

func (z *ZipFile) Create(name string) error

Create new file zip

Jump to

Keyboard shortcuts

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