com

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: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(w http.ResponseWriter, r *http.Request, err error)

ErrorHandler -

func GetCustomRequestType

func GetCustomRequestType(gRqt *http.Request) (map[string]string, []byte)

GetCustomRequestType - get custom request from HTTP Request Body

func Handle404Status

func Handle404Status(res *http.Response) error

- Throw err when proxied response status is 404

func SendRequest

func SendRequest(s Server, r Request, loging bool) (string, error)

SendRequest - send request to server

Types

type CommandRequest

type CommandRequest struct {
	Command      string
	Content      string
	Hash         string
	Name         string
	ResourcePath string
	Secret       string
	Type         string
}

CommandRequest - CommandRequest

func (*CommandRequest) Decode

func (cr *CommandRequest) Decode(b []byte)

Decode - Decode JSON to CommandRequest

func (*CommandRequest) Encode

func (cr *CommandRequest) Encode() []byte

Encode - Encode CommandRequest to JSON

func (*CommandRequest) Generate

func (cr *CommandRequest) Generate(list ...interface{})

Generate - Generate CommandRequest with params - Command string - Hash string - Name string - Secret string

func (*CommandRequest) GetPath

func (cr *CommandRequest) GetPath() string

GetPath - CommandRequest path string

func (*CommandRequest) GetSecret

func (cr *CommandRequest) GetSecret() string

GetSecret - CommandRequest request secret

func (*CommandRequest) GetType

func (cr *CommandRequest) GetType() string

GetType - CommandRequest request type

type ConnexionRequest

type ConnexionRequest struct {
	CustomCommands []string
	ModHash        string
	Name           string
	Pid            string
	Port           string
	ResourcePath   string
	Secret         string
	Type           string
	State          string
}

ConnexionRequest - server connexion request

func (*ConnexionRequest) Decode

func (cr *ConnexionRequest) Decode(b []byte)

Decode - Decode JSON to ConnexionRequest

func (*ConnexionRequest) Encode

func (cr *ConnexionRequest) Encode() []byte

Encode - Encode ConnexionRequest to JSON

func (*ConnexionRequest) Generate

func (cr *ConnexionRequest) Generate(list ...interface{})

Generate - Generate ConnexionRequest with params

func (*ConnexionRequest) GetPath

func (cr *ConnexionRequest) GetPath() string

GetPath - ConnexionRequest path string

func (*ConnexionRequest) GetSecret

func (cr *ConnexionRequest) GetSecret() string

GetSecret - ConnexionRequest request secret

func (*ConnexionRequest) GetType

func (cr *ConnexionRequest) GetType() string

GetType - ConnexionRequest request type

type Context

type Context struct {
	http.ResponseWriter
	*http.Request
	Params []string
	*RouteConfig
	*Route
}

Context -

func (*Context) ByteText

func (c *Context) ByteText(code int, body []byte) (int, error)

ByteText - Send byte text to context writer

func (*Context) HtmlText

func (c *Context) HtmlText(code int, body string, data interface{})

HtmlText - Send html text to context writer

func (*Context) Text

func (c *Context) Text(code int, body string) (int, error)

Text - Send text to context writer

type ErrorPage

type ErrorPage struct {
	Title   string
	Code    int
	Message string
}

ErrorPage - Content description for go-woxy error page

type Handler

type Handler interface {
	Handle(ctx *Context)
}

type HandlerFunc

type HandlerFunc func(*Context)

Handler - Handler endpoint function

func Error404

func Error404() HandlerFunc

func FileBind

func FileBind(fileName string, r Route) HandlerFunc

FileBind - File bind handler

func ReverseProxy

func ReverseProxy() HandlerFunc

ReverseProxyFix - reverse proxy for mod

func ReverseProxyAuth

func ReverseProxyAuth(a *auth.BasicAuth) HandlerFunc

ReverseProxyAuth - Authentication middleware

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(ctx *Context)

type IP

type IP string

IP Address

type MiddlewareFunc

type MiddlewareFunc func(Handler) Handler

func (MiddlewareFunc) Middleware

func (mw MiddlewareFunc) Middleware(handler Handler) Handler

Middleware allows MiddlewareFunc to implement the middleware interface.

type ModuleState

type ModuleState int

ModuleState - ModuleConfig State

const (
	Stopped    ModuleState = 0
	Unknown    ModuleState = 1
	Online     ModuleState = 2
	Downloaded ModuleState = 3
	Loading    ModuleState = 4

	Error  ModuleState = 999
	Failed ModuleState = 998
)

ModuleState list

type Path

type Path string

Path Server path

type PatternRoute

type PatternRoute struct {
	Pattern     *regexp.Regexp
	Handler     HandlerFunc
	RouteConfig *RouteConfig
	Route       *Route
}

PatternRoute - Module route

func (*PatternRoute) Handle

func (pr *PatternRoute) Handle(h Handler)

type Port

type Port string

Port Server port

type Protocol

type Protocol string

Protocol Server protocol

type Request

type Request interface {
	Decode(b []byte)
	Encode() []byte
	Generate(list ...interface{})
	GetPath() string
	GetType() string
	GetSecret() string
}

Request - server request

type Route

type Route struct {
	FROM string
	TO   string
}

Route - Route redirection

type RouteConfig

type RouteConfig struct {
	NAME    string
	TYPES   string
	BINDING ServerConfig
	STATE   ModuleState
}

RouteConfig - Parameter to handle route redirection

type Router

type Router struct {
	Routes       []PatternRoute
	DefaultRoute HandlerFunc
	Middlewares  []middleware
}

Router - Server router containing routes

func NewRouter

func NewRouter(NotFoundHandler HandlerFunc) *Router

NewRouter - Init new router instance

func (*Router) Handle

func (r *Router) Handle(pattern string, handler HandlerFunc, routeConfig *RouteConfig, ro *Route)

Handle - Handle new router into router

func (*Router) Handler

func (r *Router) Handler(pattern string, handler Handler, routeConfig *RouteConfig, ro *Route)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, re *http.Request)

ServerHTTP - Serve route from router

type Server

type Server struct {
	IP       IP
	Port     Port
	Path     Path
	Protocol Protocol
}

Server - Struct

type ServerConfig

type ServerConfig struct {
	ADDRESS  string
	PATH     []Route
	PORT     string
	PROTOCOL string
	ROOT     string
	CERT     string
	CERT_KEY string
}

ServerConfig - Server configuration

Jump to

Keyboard shortcuts

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