Documentation ¶
Index ¶
- Constants
- func AcquireLock(key string)
- func Debugf(format string, v ...interface{})
- func Errorf(format string, v ...interface{})
- func GetLogLevel() logLevel
- func Infof(format string, v ...interface{})
- func InitPlugin(fpath string, domain string, conf *map[string]any) (*plugin.Plugin, error)
- func IsLocked(key string) bool
- func LoadAuthPlugin(fpath string, domain string, conf *map[string]any) error
- func LoadServePlugin(fpath string, domain string, conf *map[string]any) error
- func ReleaseLock(key string)
- func SetLogLevel(level logLevel)
- func SetLogLevelStr(levelstr string) error
- func Tracef(format string, v ...interface{})
- func Warningf(format string, v ...interface{})
- type AuthFn
- type Config
- type DomainConfig
- type ServeFn
- type TupiServer
Constants ¶
const ( LevelTrace logLevel = iota LevelDebug LevelInfo LevelWarning LevelError )
const INVALID_PREFIX_MSG = "Invalid prefix"
const UPLOAD_CONTENT_TYPE = "multipart/form-data"
Variables ¶
This section is empty.
Functions ¶
func AcquireLock ¶
func AcquireLock(key string)
AcquireLock locks a resource based in a key When you are done you must release the lock with ReleaseLock()
func GetLogLevel ¶
func GetLogLevel() logLevel
func InitPlugin ¶ added in v0.6.0
InitPlugin tries to run the “Init“ function of a plugin. As it is optinal, if not found returns without error. The “Init“ function get a domain and a config map for the domain as parameters. The plugin “Init“ function signature is as follows:
func(string, map[string]any) error
InitPlugin is intended to be run as part of the server start process.
func LoadAuthPlugin ¶ added in v0.6.0
LoadAuthPlugin loads a authentication plugin looking for an “Authenticate“ function. The “Authenticate“ function gets a referece to http.Request, a domain and a config map for the domain as parameters. The signature of the “Authenticate“ function is as follows:
func(*http.Request, string, map[string]any)
LoadAuthPlugin is intended to be run as part of the server start process.
func LoadServePlugin ¶ added in v0.11.0
LoadServePlugin loads a authentication plugin looking for an “Serve“ function. The “Serve“ function gets a referece to http.Request, a domain and a config map for the domain as parameters. The signature of the “Serve“ function is as follows:
func(*http.Request, string, map[string]any)
LoadServePlugin is intended to be run as part of the server start process.
func ReleaseLock ¶
func ReleaseLock(key string)
ReleaseLock releases the lock for a given resource identified by a key.
func SetLogLevel ¶
func SetLogLevel(level logLevel)
func SetLogLevelStr ¶ added in v0.8.0
Types ¶
type AuthFn ¶ added in v0.6.0
func GetAuthPlugin ¶ added in v0.6.0
Returns an already loaded “Autenticate“ function of an auth plugin.
type Config ¶
type Config struct {
Domains map[string]DomainConfig
}
func GetConfig ¶
GetConfig returns the config struct for the server by reading the confs passed in the command line and optionally in a config file. Config file values have precedence over command line values
func GetConfigFromFile ¶
type DomainConfig ¶
type DomainConfig struct { Host string Port int AlternativePort int RootDir string Timeout int HtpasswdFile string UploadPath string ExtractPath string MaxUploadSize int64 CertFilePath string KeyFilePath string DefaultToIndex bool ConfigFile string AuthPlugin string AuthPluginConf map[string]interface{} ServePlugin string ServePluginConf map[string]interface{} LogLevel string PreventOverwrite bool AuthMethods []string // contains filtered or unexported fields }
func GetConfigFromCommandLine ¶
func GetConfigFromCommandLine() DomainConfig
func (*DomainConfig) HasCert ¶
func (c *DomainConfig) HasCert() bool
func (*DomainConfig) HasKey ¶
func (c *DomainConfig) HasKey() bool
func (*DomainConfig) Validate ¶
func (c *DomainConfig) Validate() error
type ServeFn ¶ added in v0.11.0
func GetServePlugin ¶ added in v0.11.0
Returns an already loaded "Serve" function of a serve plugin
type TupiServer ¶
type TupiServer struct { Conf Config // We have one server for each port we listen Servers []*http.Server }
func SetupServer ¶
func SetupServer(conf Config) TupiServer
SetupServer creates a new instance of the tupi http server. You can start it using “TupiServer.Run“
func (*TupiServer) LoadPlugins ¶ added in v0.6.1
func (s *TupiServer) LoadPlugins()
func (*TupiServer) Run ¶
func (s *TupiServer) Run()