Documentation ¶
Index ¶
- func ErrorHandler(w http.ResponseWriter, r *http.Request, err error)
- func GetCustomRequestType(gRqt *http.Request) (map[string]string, []byte)
- func Handle404Status(res *http.Response) error
- func SendRequest(s Server, r Request, loging bool) (string, error)
- type CommandRequest
- type ConnexionRequest
- type Context
- type ErrorPage
- type Handler
- type HandlerFunc
- type IP
- type MiddlewareFunc
- type ModuleState
- type Path
- type PatternRoute
- type Port
- type Protocol
- type Request
- type Route
- type RouteConfig
- type Router
- type Server
- type ServerConfig
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 ¶
GetCustomRequestType - get custom request from HTTP Request Body
func Handle404Status ¶
- Throw err when proxied response status is 404
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 -
type HandlerFunc ¶
type HandlerFunc func(*Context)
Handler - Handler endpoint function
func Error404 ¶
func Error404() HandlerFunc
func ReverseProxyAuth ¶
func ReverseProxyAuth(a *auth.BasicAuth) HandlerFunc
ReverseProxyAuth - Authentication middleware
func (HandlerFunc) Handle ¶
func (h HandlerFunc) Handle(ctx *Context)
type MiddlewareFunc ¶
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 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 Request ¶
type Request interface { Decode(b []byte) Encode() []byte Generate(list ...interface{}) GetPath() string GetType() string GetSecret() string }
Request - server request
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