ettp

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	CONNECT    = "CONNECT"
	DELETE     = "DELETE"
	GET        = "GET"
	HEAD       = "HEAD"
	OPTIONS    = "OPTIONS"
	PATCH      = "PATCH"
	POST       = "POST"
	PUT        = "PUT"
	TRACE      = "TRACE"
	ROUTER_KEY = "apigateway-router"
)
View Source
const (
	MetricKey   claim.ContextKey = "metric"
	ResoluteKey claim.ContextKey = "resolute"
)
View Source
const QP = "?"

Variables

This section is empty.

Functions

func CorsAllowAll

func CorsAllowAll(allowedOrigins []string) *cors.Cors

Types

type ApiFunc added in v0.1.1

type ApiFunc struct {
	Id          string
	Method      string
	Path        string
	HandlerFn   http.HandlerFunc
	PackageName string
}

func NewApiFunc added in v0.1.1

func NewApiFunc(id, method, path string, h http.HandlerFunc, packageName string) *ApiFunc

* * NewApiFunc * @param id, method, path string, h http.HandlerFunc, packageName string * @return *ApiFunc *

type Config

type Config struct {
	Name         string
	Company      string
	Web          string
	Help         string
	Port         int
	PathApi      string
	PathApp      string
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
	TLS          bool
	CertFile     string
	KeyFile      string
	Debug        bool
}

type Package

type Package struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// contains filtered or unexported fields
}

func (*Package) Describe added in v0.1.0

func (s *Package) Describe() et.Json

* * Describe * @return et.Json *

type Proxy added in v0.1.1

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 added in v0.1.1

func NewProxy(id, path, name, description, solver, packageName string, s *Server) *Proxy

* * NewProxy * @param id, path, name, description, solver, packageName string, s *Server * @return *Proxy *

func (*Proxy) ResetPortForward added in v0.1.1

func (s *Proxy) ResetPortForward() error

* * ResetPortForward * @return error *

func (*Proxy) ServeHTTP added in v0.1.1

func (s *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

* * ServeHTTP * @param w http.ResponseWriter, r *http.Request *

func (*Proxy) StartPortForward added in v0.1.1

func (s *Proxy) StartPortForward() error

* * StartPortForward * @return error *

func (*Proxy) StopPortForward added in v0.1.1

func (s *Proxy) StopPortForward() error

* * StopPortForward * @return error *

func (*Proxy) ToJson added in v0.1.1

func (p *Proxy) ToJson() et.Json

* * ToJson * @return et.Json *

type Resolver added in v0.1.1

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 added in v0.1.1

func (s *Resolver) GetResolve() string

* * GetResolve * @return string *

func (*Resolver) ToJson added in v0.1.1

func (s *Resolver) ToJson() et.Json

* * ToJson * @return et.Json *

func (*Resolver) ToString added in v0.1.1

func (s *Resolver) ToString() string

* * ToString * @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 *

func (*Router) ToJson

func (r *Router) ToJson() et.Json

* * ToJson * @return et.Json *

func (*Router) Trace

func (r *Router) Trace(path string, handlerFn http.HandlerFunc, packageName string)

* * Trace * @param path string, handlerFn http.HandlerFunc, packageName string *

func (*Router) With

func (r *Router) With(middlewares ...func(http.Handler) http.Handler) *Router

* * With * @param middlewares ...func(http.HandlerFunc) http.HandlerFunc * @return *Router *

type Server

type Server struct {
	CreatedAt time.Time
	Id        string
	Name      string
	Version   string
	Company   string
	Web       string
	Help      string
	HostName  string
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Server, error)

func (*Server) Authenticator

func (s *Server) Authenticator(middleware func(http.Handler) http.Handler) *Server

* * Authenticator * @param middleware func(http.HandlerFunc) http.HandlerFunc * @return *Server *

func (*Server) AuthorizationRoute

func (s *Server) AuthorizationRoute(method, path string, h http.HandlerFunc, packageName string)

* * AuthorizationRoute * @param method, path, handlerFn, packageName string *

func (*Server) Close

func (s *Server) Close()

* * Close *

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 added in v0.1.1

func (s *Server) DeleteProxyById(id string, save bool) error

* * DeleteProxyById * @param id string * @return error *

func (*Server) DeleteProxys added in v0.1.1

func (s *Server) DeleteProxys(w http.ResponseWriter, r *http.Request)

* * DeleteProxys * @params w http.ResponseWriterz * @params r *http.Request *

func (*Server) DeleteRouteById

func (s *Server) DeleteRouteById(id string, save bool) error

* * DeleteRouteById * @param id string * @return error *

func (*Server) DeleteTokenByKey

func (s *Server) DeleteTokenByKey(key string) error

* * 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

func (s *Server) GetPackages(name string) et.Items

* * GetPackages * @return et.Items *

func (*Server) GetProxys added in v0.1.1

func (s *Server) GetProxys(w http.ResponseWriter, r *http.Request)

* * GetProxys * @params w http.ResponseWriter * @params r *http.Request *

func (*Server) GetProxysById added in v0.1.1

func (s *Server) GetProxysById(w http.ResponseWriter, r *http.Request)

* * GetProxysById * @params w http.ResponseWriter * @params r *http.Request *

func (*Server) GetRouteById

func (s *Server) GetRouteById(id string) *Router

* * GetRouteById * @param id string * @return *Router *

func (*Server) GetRouter added in v0.1.1

func (s *Server) GetRouter() et.Items

* * GetRouter * @return et.Items *

func (*Server) GetTokenByKey

func (s *Server) GetTokenByKey(key string) (et.Item, error)

* * GetTokenByKey * @param key string * @return error *

func (*Server) HandlerValidToken

func (s *Server) HandlerValidToken(key string) (et.Item, error)

* * 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) Private

func (s *Server) Private() *Router

* * Private * @return *Router *

func (*Server) PrivateRoute added in v0.1.1

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) Reset

func (s *Server) Reset() error

* * Reset *

func (*Server) Save

func (s *Server) Save() error

* * Save * @return error *

func (*Server) SetAddr

func (s *Server) SetAddr(port int)

* * SetAddr * @param port int *

func (*Server) SetAuthorizationMiddleware added in v0.1.1

func (s *Server) SetAuthorizationMiddleware(f func(next http.Handler) http.Handler)

* * SetAuthorizationMiddleware * @param f middleware.AuthorizationMiddleware *

func (*Server) SetIdleTimeout

func (s *Server) SetIdleTimeout(value time.Duration)

* * SetIdleTimeout * @param h http.Handler *

func (*Server) SetPortForward added in v0.1.1

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 added in v0.1.1

func (s *Server) SetPortForwards(w http.ResponseWriter, r *http.Request)

* * SetPortForwards * @params w http.ResponseWriter * @params r *http.Request *

func (*Server) SetProxy added in v0.1.1

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 added in v0.1.1

func (s *Server) SetProxys(w http.ResponseWriter, r *http.Request)

* * SetProxys * @params w http.ResponseWriter * @params r *http.Request *

func (*Server) SetReadTimeout

func (s *Server) SetReadTimeout(value time.Duration)

* * SetNotFoundHandler * @param h http.Handler *

func (*Server) SetRouter added in v0.1.1

func (s *Server) SetRouter(private bool, id, method, path, resolve string, header et.Json, tpHeader rt.TpHeader, excludeHeader []string, packageName string, saved bool) (*Router, error)

* * SetRouter * @param private bool, id, method, path, resolve string, header et.Json, tpHeader rt.TpHeader, excludeHeader []string, packageName string, saved bool * @return *Router, error *

func (*Server) SetWriteTimeout

func (s *Server) SetWriteTimeout(value time.Duration)

* * SetWriteTimeout * @param h http.Handler *

func (*Server) Start

func (s *Server) Start() error

* * Start *

func (*Server) StartWS added in v0.1.1

func (s *Server) StartWS() error

* * StartWS *

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) Use

func (s *Server) Use(middlewares ...func(http.Handler) http.Handler)

* * Use * @param middlewares ...func(http.HandlerFunc) http.HandlerFunc *

func (*Server) With

func (s *Server) With(middlewares ...func(http.Handler) http.Handler) *Router

* * With * @param middlewares ...func(http.HandlerFunc) http.HandlerFunc *

type Storage added in v0.1.1

type Storage struct {
	Router  []*Router
	Proxy   map[string]*Proxy
	Version string
}

func NewStorage added in v0.1.1

func NewStorage() *Storage

type TpParams

type TpParams int
const (
	TpPathParams TpParams = iota
	TpQueryParams
	TpMatrixParams
	TpNotParams
)

func (TpParams) String

func (t TpParams) String() string

type TypeApi

type TypeApi int
const (
	TpHandler TypeApi = iota
	TpApiRest
	TpProxy
	TpPortForward
)

func IntToTypeApi

func IntToTypeApi(i int) TypeApi

func (TypeApi) String

func (t TypeApi) String() string

Jump to

Keyboard shortcuts

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