server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Time0 time.Time

Time0 represents initial time when we started the server

View Source
var TotalDeleteRequests uint64

TotalDeleteRequests counts total number of DELETE requests received by the server

View Source
var TotalGetRequests uint64

TotalGetRequests counts total number of GET requests received by the server

View Source
var TotalPostRequests uint64

TotalPostRequests counts total number of POST requests received by the server

View Source
var TotalPutRequests uint64

TotalPutRequests counts total number of PUT requests received by the server

Functions

func ApisHandler added in v0.0.1

func ApisHandler(c *gin.Context)

ApisHandler provides JSON output for server routes

func CaptchaHandler

func CaptchaHandler() gin.HandlerFunc

CaptchaHandler provides access to captcha server

func CounterMiddleware

func CounterMiddleware() gin.HandlerFunc

CounterMiddleware counts GET/POST/PUT/DELETE requests

func ErrorPage

func ErrorPage(fsys fs.FS, msg string, err error) string

ErrorPage returns error page

func ErrorTmpl

func ErrorTmpl(fsys fs.FS, msg string, err error) string

ErrorTmpl provides error template message

func FAQPage added in v0.0.1

func FAQPage(fsys fs.FS) string

FAQPage provides FAQ page

func FooterPage

func FooterPage(fsys fs.FS) string

FooterPage returns footer page

func HeaderPage

func HeaderPage(fsys fs.FS) string

HeaderPage returns header page

func ParseTmpl added in v0.0.1

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

ParseTmpl parses template with given data

func Router added in v0.0.1

func Router(routes []Route, fsys fs.FS, static, base string, verbose int) *gin.Engine

Router provids server router, it takes two maps: one for non-authorized routes and anotehr for authorized ones

func SuccessTmpl

func SuccessTmpl(fsys fs.FS, msg string) string

SuccessTmpl provides success template message

func TmplPage added in v0.0.1

func TmplPage(fsys fs.FS, tmpl string, tmplData TmplRecord) string

TmplPage parses given template and return HTML page

Types

type GinRoute added in v0.0.1

type GinRoute struct {
	Method string `json:"method"`
	Path   string `json:"path"`
}

GinRoute represents git route info

type Mem

type Mem struct {
	Virtual Memory
	Swap    Memory
}

Mem structure keeps track of virtual/swap memory of the server

type Memory

type Memory struct {
	Total       uint64  `json:"total"`
	Free        uint64  `json:"free"`
	Used        uint64  `json:"used"`
	UsedPercent float64 `json:"usedPercent"`
}

Memory structure keeps track of server memory

type Route added in v0.0.1

type Route struct {
	Method     string
	Path       string
	Handler    gin.HandlerFunc
	Authorized bool
}

Route represents routes structure

type Templates added in v0.0.1

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

Templates structure

func (Templates) TextTmpl added in v0.0.1

func (q Templates) TextTmpl(fsys fs.FS, tfile string, tmplData map[string]interface{}) string

Tmpl method for ServerTemplates structure

func (Templates) Tmpl added in v0.0.1

func (q Templates) Tmpl(fsys fs.FS, tfile string, tmplData map[string]interface{}) string

Tmpl method for ServerTemplates structure

type TmplRecord added in v0.0.1

type TmplRecord map[string]interface{}

TmplRecord represent template record

func MakeTmpl

func MakeTmpl(fsys fs.FS, title string) TmplRecord

helper function to make initial template struct

func MetricsPage

func MetricsPage(fsys fs.FS) TmplRecord

MetricsPage represents metrics page

func (TmplRecord) GetBytes added in v0.0.1

func (t TmplRecord) GetBytes(key string) []byte

GetBytes returns bytes object for given key

func (TmplRecord) GetElapsedTime added in v0.0.1

func (t TmplRecord) GetElapsedTime() string

GetElapsedTime returns elapsed time

func (TmplRecord) GetError added in v0.0.1

func (t TmplRecord) GetError() string

GetError returns error string

func (TmplRecord) GetInt added in v0.0.1

func (t TmplRecord) GetInt(key string) int

GetInt converts given value for provided key to int data-type

func (TmplRecord) GetString added in v0.0.1

func (t TmplRecord) GetString(key string) string

GetString converts given value for provided key to string data-type

Jump to

Keyboard shortcuts

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