swordtech

package module
v0.0.0-...-242dd47 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 18 Imported by: 0

README

swordtech

Web framework for Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBackgroundProcess

func AddBackgroundProcess(f func() error)

AddBackgroundProcess adds a function that will be executed in the background

func AddBatchProcess

func AddBatchProcess(f func() error)

AddBatchProcess adds a function to be executed once a day

func AddFunc

func AddFunc(n string, f interface{})

func AddStartup

func AddStartup(s func())

AddStartup adds a function to the startup

func GetSessionVar

func GetSessionVar(r *http.Request, name string) interface{}

GetSessionVar returns the value of the specified session variable

func Log

func Log(method *string, ip *string, text string, result int)

Log outputs a message to the daily log file

func Panic

func Panic(method *string, ip *string, text string, result int)

Panic logs the entry and raises a panic

func RemoveAllSessionVars

func RemoveAllSessionVars(r *http.Request, w http.ResponseWriter)

RemoveAllSessionVars clears all the session variables

func RemoveSessionVar

func RemoveSessionVar(r *http.Request, w http.ResponseWriter, name string)

RemoveSessionVar removes the session variable

func RunApp

func RunApp(r func(*mux.Router))

RunApp starts the server

func Session

func Session(r *http.Request) (*sessions.Session, error)

Session returns the current session

func SessionName

func SessionName() string

SessionName returns the name of the session

func SetErrorMiddleware

func SetErrorMiddleware(f func(w http.ResponseWriter, r *http.Request, err error) bool)

SetErrorMiddleware sets the custom error handler Return true if the error middleware handles the request

func SetMiddleware

func SetMiddleware(f func(w http.ResponseWriter, r *http.Request) bool)

SetMiddleware sets the custom middleware Return true if the middleware handles the request

func SetSessionVar

func SetSessionVar(r *http.Request, w http.ResponseWriter, name string, value interface{})

SetSessionVar sets and saves the session variable

Types

type Config

type Config struct {
	Server          ServerConfig   `json:"server"`
	Database        DatabaseConfig `json:"database"`
	Secret          string         `json:"secret"`
	ApplicationName string         `json:"appname"`
	ShowLog         bool           `json:"showlog"`
}

Config is the application configuration

type DatabaseConfig

type DatabaseConfig struct {
	Server   string `json:"server"`
	Port     int    `json:"port"`
	Database string `json:"database"`
	User     string `json:"username"`
	Password string `json:"password"`
}

DatabaseConfig is the database configuration

type LogMsg

type LogMsg struct {
	daggertech.Model
	IP                string `daggertech:"size:20"`
	Method            string `daggertech:"size:32"`
	Text              string `daggertech:""`
	Result            int    `daggertech:""`
	ResultDescription string `daggertech:""`
}

LogMsg is the log message to be stored in the database

func (*LogMsg) ToString

func (l *LogMsg) ToString() string

ToString returns the string representation of the error

type Parameter

type Parameter struct {
	daggertech.Model
	Name             string `daggertech:"size:64,key:true"`
	Value            string `daggertech:""`
	Description      string `daggertech:""`
	ParameterGroupID string `daggertech:"type:uuid,key:true"`
}

Parameter is the table to hold the global parameters

func GetParameter

func GetParameter(group string, name string, description string, defaultValue string) *Parameter

GetParameter returns the parameter specified If necessary, a new parameter group is created

func (*Parameter) Bool

func (p *Parameter) Bool() bool

Bool returns the bool value of the paraneter

func (*Parameter) Float

func (p *Parameter) Float() float64

Float returns the float64 value of the parameter

func (*Parameter) Int

func (p *Parameter) Int() int64

Int returns the int64 value of the parameter

func (*Parameter) Set

func (p *Parameter) Set(v interface{})

Set sets the value of the paraneter and automatically saves it to the database

func (Parameter) StandingData

func (p Parameter) StandingData() []daggertech.Modeller

StandingData returns the standing data for when the table is created

func (*Parameter) String

func (p *Parameter) String() string

String returns the string value of the parameter

func (*Parameter) Time

func (p *Parameter) Time() *time.Time

Time returns the time value of the parameter, or nil if the value cannot be converted

type ParameterGroup

type ParameterGroup struct {
	daggertech.Model
	Name string `daggertech:"size:64,key:true"`
}

ParameterGroup is the table to hold the global parameter groupss

func (*ParameterGroup) GetParameters

func (g *ParameterGroup) GetParameters() []*Parameter

GetParameters returns all the parameters for the parameter group passed as receiver

func (ParameterGroup) StandingData

func (g ParameterGroup) StandingData() []daggertech.Modeller

StandingData returns the standing data for when the table is created

type Request

type Request struct {
	*http.Request
	IPAddress string
}

Request is an enhanced http.Request

func NewRequest

func NewRequest(r *http.Request) *Request

NewRequest creates a new HiveRequest

type Response

type Response struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

Response allows the status of the response to be exposed for logging

func NewResponse

func NewResponse(r http.ResponseWriter) *Response

NewResponse creates a new HiveResponse

func (*Response) Status

func (r *Response) Status() int

Status retrieves the status code of the response

func (*Response) WriteHeader

func (r *Response) WriteHeader(code int)

WriteHeader overrites the original method to allow retrieval of the status code

type ServerConfig

type ServerConfig struct {
	Port    int    `json:"port"`
	UseSSL  bool   `json:"usessl"`
	SSLCert string `json:"sslcert"`
	SSLKey  string `json:"sslkey"`
}

ServerConfig is the server configuration

Directories

Path Synopsis
models

Jump to

Keyboard shortcuts

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