Documentation
¶
Index ¶
- Constants
- func CorsAllowAll(allowedOrigins []string) *cors.Cors
- type ApiFunc
- type Config
- type Package
- type Proxy
- type Resolver
- type Router
- func (r *Router) Connect(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) Delete(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) Get(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) Head(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) Options(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) Patch(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) Post(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) Put(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) ToJson() et.Json
- func (r *Router) Trace(path string, handlerFn http.HandlerFunc, packageName string)
- func (r *Router) With(middlewares ...func(http.Handler) http.Handler) *Router
- type Server
- func (s *Server) Close()
- func (s *Server) Connect(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) Delete(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) DeleteProxyById(id string, save bool) error
- func (s *Server) DeleteProxys(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteRouteById(id string, save bool) error
- func (s *Server) DeleteTokenByKey(key string) error
- func (s *Server) Get(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) GetPackages(name string) et.Items
- func (s *Server) GetProxys(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetProxysById(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetRouteById(id string) *Router
- func (s *Server) GetTokenByKey(key string) (et.Item, error)
- func (s *Server) HandlerValidToken(key string) (et.Item, error)
- func (s *Server) Head(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) Options(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) Patch(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) Post(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) Private() *Router
- func (s *Server) PrivateRoute(method, path string, h http.HandlerFunc, packageName string)
- func (s *Server) ProtectRoute(method, path string, h http.HandlerFunc, packageName string)
- func (s *Server) PublicRoute(method, path string, h http.HandlerFunc, packageName string)
- func (s *Server) Put(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) Reset() error
- func (s *Server) Save() error
- func (s *Server) SetAddr(port int)
- func (s *Server) SetIdleTimeout(value time.Duration)
- func (s *Server) SetPortForward(id, name, description, remoteHost string, remotePort, localPort int, ...) (*Proxy, error)
- func (s *Server) SetPortForwards(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetProxy(id, path, name, description, solver, packageName string, save bool) (*Proxy, error)
- func (s *Server) SetProxys(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetReadTimeout(value time.Duration)
- func (s *Server) SetRouter(private bool, method, path, resolve string, header et.Json, ...) (*Router, error)
- func (s *Server) SetWriteTimeout(value time.Duration)
- func (s *Server) Start() error
- func (s *Server) Trace(path string, handlerFn http.HandlerFunc, packageName string)
- func (s *Server) Use(middlewares ...func(http.Handler) http.Handler)
- func (s *Server) UseAuthentication(middleware func(http.Handler) http.Handler) *Server
- func (s *Server) With(middlewares ...func(http.Handler) http.Handler) *Router
- type Storage
- type TpParams
- type TransportConfig
- type TypeApi
Constants ¶
const ( MSG_ROUTE_ADD = "ruta agregada" MSG_ROUTE_UPDATE = "ruta actualizada" MSG_ROUTE_DELETE = "ruta eliminada" MSG_ROUTE_NOT_FOUND = "ruta no encontrada" MSG_ROUTE_NOT_REGISTER = "ruta no registrada" MSG_METRIC_NOT_FOUND = "metrics no definido" MSG_PACKAGE_DELETE = "paquete eliminado" MSG_APIGATEWAY_RESET = "%s reseted" MSG_METHOD_NOT_FOUND = "%s http method is not supported." MSG_TOKEN_VALID = "token valido" MSG_INVALID_KIND = "invalid kind: %s" MSG_PROXY_NOT_FOUND = "proxy no encontrado" MSG_PROXY_DELETE = "proxy eliminado" MSG_IS_PORTFORWARD = "is portforward" )
const ( CONNECT = "CONNECT" DELETE = "DELETE" GET = "GET" HEAD = "HEAD" OPTIONS = "OPTIONS" PATCH = "PATCH" POST = "POST" PUT = "PUT" TRACE = "TRACE" ROUTER_KEY = "apigateway-router" )
const ( MetricKey request.ContextKey = "metric" ResoluteKey request.ContextKey = "resolute" )
const QP = "?"
Variables ¶
This section is empty.
Functions ¶
func CorsAllowAll ¶
Types ¶
type ApiFunc ¶
type ApiFunc struct {
Id string
Method string
Path string
HandlerFn http.HandlerFunc
PackageName string
}
func NewApiFunc ¶
func NewApiFunc(method, path string, h http.HandlerFunc, packageName string) *ApiFunc
* * NewApiFunc * @param method, path string, h http.HandlerFunc, packageName string * @return *ApiFunc *
type Config ¶
type Config struct {
Name string `json:"name"`
Company string `json:"company"`
Web string `json:"web"`
Help string `json:"help"`
Port int `json:"port"`
PathApi string `json:"path_api"`
PathApp string `json:"path_app"`
ReadTimeout time.Duration `json:"read_timeout"`
WriteTimeout time.Duration `json:"write_timeout"`
IdleTimeout time.Duration `json:"idle_timeout"`
IsTLS bool `json:"is_tls"`
CertFile string `json:"cert_file"`
KeyFile string `json:"key_file"`
Transport *TransportConfig `json:"transport"`
Timeout time.Duration `json:"timeout"`
Debug bool `json:"debug"`
}
type Package ¶
type Proxy ¶
type Proxy struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Path string `json:"path"`
Solver string `json:"solver"`
Kind TypeApi `json:"kind"`
PackageName string `json:"package_name"`
RemoteHost string `json:"remote_host"`
RemotePort int `json:"remote_port"`
LocalPort int `json:"local_port"`
// contains filtered or unexported fields
}
func NewProxy ¶
* * NewProxy * @param id, path, name, description, solver, packageName string, s *Server * @return *Proxy *
func (*Proxy) ResetPortForward ¶
* * ResetPortForward * @return error *
func (*Proxy) ServeHTTP ¶
func (s *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
* * ServeHTTP * @param w http.ResponseWriter, r *http.Request *
func (*Proxy) StartPortForward ¶
* * StartPortForward * @return error *
func (*Proxy) StopPortForward ¶
* * StopPortForward * @return error *
type Resolver ¶
type Resolver struct {
Server *Server
Method string
Proto string
Path string
RawQuery string
Query url.Values
RequestURI string
RemoteAddr string
Header http.Header
Body interface{}
Host string
Scheme string
URL string
Router *Router
}
func (*Resolver) GetResolve ¶
* * GetResolve * @return string *
type Router ¶
type Router struct {
Id string `json:"id"`
Tag string `json:"tag"`
TpParams TpParams `json:"tp_params"`
Kind TypeApi `json:"kind"`
Method string `json:"method"`
Resolve string `json:"resolve"`
Path string `json:"path"`
Header et.Json `json:"header"`
TpHeader router.TpHeader `json:"tp_header"`
ExcludeHeader []string `json:"exclude_header"`
Private bool `json:"private"`
PackageName string `json:"package_name"`
Routes []*Router `json:"routes"`
// contains filtered or unexported fields
}
func (*Router) Connect ¶
func (r *Router) Connect(path string, handlerFn http.HandlerFunc, packageName string)
* * Connect * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Router) Delete ¶
func (r *Router) Delete(path string, handlerFn http.HandlerFunc, packageName string)
* * Delete * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Router) Get ¶
func (r *Router) Get(path string, handlerFn http.HandlerFunc, packageName string)
* * Get * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Router) Head ¶
func (r *Router) Head(path string, handlerFn http.HandlerFunc, packageName string)
* * Head * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Router) Options ¶
func (r *Router) Options(path string, handlerFn http.HandlerFunc, packageName string)
* * Options * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Router) Patch ¶
func (r *Router) Patch(path string, handlerFn http.HandlerFunc, packageName string)
* * Patch * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Router) Post ¶
func (r *Router) Post(path string, handlerFn http.HandlerFunc, packageName string)
* * Post * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Router) Put ¶
func (r *Router) Put(path string, handlerFn http.HandlerFunc, packageName string)
* * Put * @param path string, handlerFn http.HandlerFunc, packageName string *
type Server ¶
type Server struct {
CreatedAt time.Time `json:"created_at"`
Id string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Company string `json:"company"`
Web string `json:"web"`
Help string `json:"help"`
HostName string `json:"host_name"`
// contains filtered or unexported fields
}
func (*Server) Connect ¶
func (s *Server) Connect(path string, handlerFn http.HandlerFunc, packageName string)
* * Connect * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) Delete ¶
func (s *Server) Delete(path string, handlerFn http.HandlerFunc, packageName string)
* * Delete * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) DeleteProxyById ¶
* * DeleteProxyById * @param id string * @return error *
func (*Server) DeleteProxys ¶
func (s *Server) DeleteProxys(w http.ResponseWriter, r *http.Request)
* * DeleteProxys * @params w http.ResponseWriterz * @params r *http.Request *
func (*Server) DeleteRouteById ¶
* * DeleteRouteById * @param id string * @return error *
func (*Server) DeleteTokenByKey ¶
* * DeleteTokenByKey * @param id string * @return error *
func (*Server) Get ¶
func (s *Server) Get(path string, handlerFn http.HandlerFunc, packageName string)
* * Get * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) GetPackages ¶
* * GetPackages * @return et.Items *
func (*Server) GetProxys ¶
func (s *Server) GetProxys(w http.ResponseWriter, r *http.Request)
* * GetProxys * @params w http.ResponseWriter * @params r *http.Request *
func (*Server) GetProxysById ¶
func (s *Server) GetProxysById(w http.ResponseWriter, r *http.Request)
* * GetProxysById * @params w http.ResponseWriter * @params r *http.Request *
func (*Server) GetRouteById ¶
* * GetRouteById * @param id string * @return *Router *
func (*Server) GetTokenByKey ¶
* * GetTokenByKey * @param key string * @return error *
func (*Server) HandlerValidToken ¶
* * handlerValidToken * @param key string * @return error *
func (*Server) Head ¶
func (s *Server) Head(path string, handlerFn http.HandlerFunc, packageName string)
* * Head * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) Options ¶
func (s *Server) Options(path string, handlerFn http.HandlerFunc, packageName string)
* * Options * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) Patch ¶
func (s *Server) Patch(path string, handlerFn http.HandlerFunc, packageName string)
* * Patch * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) Post ¶
func (s *Server) Post(path string, handlerFn http.HandlerFunc, packageName string)
* * Post * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) PrivateRoute ¶
func (s *Server) PrivateRoute(method, path string, h http.HandlerFunc, packageName string)
* * PrivateRoute * @param method, path, handlerFn, packageName string *
func (*Server) ProtectRoute ¶
func (s *Server) ProtectRoute(method, path string, h http.HandlerFunc, packageName string)
* * ProtectRoute * @param method, path, handlerFn, packageName string *
func (*Server) PublicRoute ¶
func (s *Server) PublicRoute(method, path string, h http.HandlerFunc, packageName string)
* * PublicRoute * @param method, path, handlerFn, packageName string *
func (*Server) Put ¶
func (s *Server) Put(path string, handlerFn http.HandlerFunc, packageName string)
* * Put * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) SetIdleTimeout ¶
* * SetIdleTimeout * @param h http.Handler *
func (*Server) SetPortForward ¶
func (s *Server) SetPortForward(id, name, description, remoteHost string, remotePort, localPort int, packageName string, save bool) (*Proxy, error)
* * setPortForward * @param id, path, name, description, remoteHost string, remotePort, localPort int, packageName string, save bool * @return *Proxy, error *
func (*Server) SetPortForwards ¶
func (s *Server) SetPortForwards(w http.ResponseWriter, r *http.Request)
* * SetPortForwards * @params w http.ResponseWriter * @params r *http.Request *
func (*Server) SetProxy ¶
func (s *Server) SetProxy(id, path, name, description, solver, packageName string, save bool) (*Proxy, error)
* * setProxy * @param id, path, name, description, solver, packageName string, save bool * @return *Proxy, error *
func (*Server) SetProxys ¶
func (s *Server) SetProxys(w http.ResponseWriter, r *http.Request)
* * SetProxys * @params w http.ResponseWriter * @params r *http.Request *
func (*Server) SetReadTimeout ¶
* * SetNotFoundHandler * @param h http.Handler *
func (*Server) SetRouter ¶
func (s *Server) SetRouter(private bool, method, path, resolve string, header et.Json, tpHeader rt.TpHeader, excludeHeader []string, packageName string, saved bool) (*Router, error)
* * SetRouter * @param private bool, method, path, resolve string, header et.Json, tpHeader rt.TpHeader, excludeHeader []string, packageName string, saved bool * @return *Router, error *
func (*Server) SetWriteTimeout ¶
* * SetWriteTimeout * @param h http.Handler *
func (*Server) Trace ¶
func (s *Server) Trace(path string, handlerFn http.HandlerFunc, packageName string)
* * Trace * @param path string, handlerFn http.HandlerFunc, packageName string *
func (*Server) UseAuthentication ¶ added in v1.0.44
* * UseAuthentication * @param middleware func(http.HandlerFunc) http.HandlerFunc * @return *Server *
type Storage ¶
func NewStorage ¶
func NewStorage() *Storage
type TransportConfig ¶ added in v1.0.22
type TransportConfig struct {
InsecureSkipVerify bool `json:"insecure_skip_verify"`
MaxIdleConns int `json:"max_idle_conns"`
MaxIdleConnsPerHost int `json:"max_idle_conns_per_host"`
MaxConnsPerHost int `json:"max_conns_per_host"`
IdleConnTimeout int `json:"idle_conn_timeout"`
TLSHandshakeTimeout int `json:"tls_handshake_timeout"`
ForceAttemptHTTP2 bool `json:"force_attempt_http2"`
}