modbase

package module
v0.0.0-...-56e812d Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetModManager

func GetModManager() *modManager

GetModManager -

Types

type HttpServer

type HttpServer struct {
	http.Server
	// contains filtered or unexported fields
}

func (*HttpServer) ShutdownHandler

func (s *HttpServer) ShutdownHandler(w http.ResponseWriter, r *http.Request)

func (*HttpServer) WaitShutdown

func (s *HttpServer) WaitShutdown()

type Module

type Module interface {
	Init()
	Register(string, func(w http.ResponseWriter, r *http.Request), string)
	Run()
	Stop()
	SetServer()
	SetHubServer()
	SetCommand(string, func(r *com.Request, w http.ResponseWriter, re *http.Request, mod *ModuleImpl) (string, error))
}

Module - Module

type ModuleImpl

type ModuleImpl struct {
	Mode           string
	Name           string
	InstanceName   string
	Router         *com.Router
	Hash           string
	Secret         string
	HubServer      com.Server
	Server         com.Server
	ResourcePath   string
	Certs          []string
	CustomCommands map[string]func(r *com.Request, w http.ResponseWriter, re *http.Request, mod *ModuleImpl) (string, error)
}

ModuleImpl - Impl of Module

func (*ModuleImpl) Init

func (mod *ModuleImpl) Init()

Init - init module

func (*ModuleImpl) Register

func (mod *ModuleImpl) Register(path string, handler com.HandlerFunc, typeM string)

TODO ADD CUSTOM LOGGING Register - register http handler for path

func (*ModuleImpl) Run

func (mod *ModuleImpl) Run()

Run - start module function

func (*ModuleImpl) SetAddress

func (mod *ModuleImpl) SetAddress(addr string)

SetAddress - Set address for server

func (*ModuleImpl) SetCerts

func (mod *ModuleImpl) SetCerts(keyPath string, certPath string)

SetCerts - Set certificate and key for server

func (*ModuleImpl) SetCommand

func (mod *ModuleImpl) SetCommand(name string, run func(r *com.Request, w http.ResponseWriter, re *http.Request, mod *ModuleImpl) (string, error))

SetCommand - set command

func (*ModuleImpl) SetHubAddress

func (mod *ModuleImpl) SetHubAddress(addr string)

SetHubAddress - Set address for hub server

func (*ModuleImpl) SetHubPath

func (mod *ModuleImpl) SetHubPath(path string)

SetHubPath - Set path for hub server

func (*ModuleImpl) SetHubPort

func (mod *ModuleImpl) SetHubPort(port string)

SetHubPort - Set port for hub server

func (*ModuleImpl) SetHubProtocol

func (mod *ModuleImpl) SetHubProtocol(proto string)

SetHubProtocol - Set protocol for hub server

func (*ModuleImpl) SetHubServer

func (mod *ModuleImpl) SetHubServer(ip string, path string, port string, proto string)

SetHubServer -

func (*ModuleImpl) SetPath

func (mod *ModuleImpl) SetPath(path string)

SetPath - Set path for server

func (*ModuleImpl) SetPort

func (mod *ModuleImpl) SetPort(port string)

SetPort - Set port for server

func (*ModuleImpl) SetProtocol

func (mod *ModuleImpl) SetProtocol(proto string)

SetProtocol - Set protocol for server

func (*ModuleImpl) SetServer

func (mod *ModuleImpl) SetServer(ip string, path string, port string, proto string)

SetServer -

func (*ModuleImpl) Stop

func (mod *ModuleImpl) Stop(w http.ResponseWriter, r *http.Request)

Stop - stop module

Jump to

Keyboard shortcuts

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