types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamLocationPath   = "path"
	ParamLocationQuery  = "query"
	ParamLocationHeader = "header"
	ParamLocationCookie = "cookie"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IAPIRoute

type IAPIRoute interface {
	Wrap(middlewares ...Middleware)
}

type IAPIRouter

type IAPIRouter interface {
	WEBSOCKET(path string, handler interface{}, origin func(r *http.Request) bool) IAPIRoute
	GET(path string, handler interface{}) IAPIRoute
	POST(path string, handler interface{}) IAPIRoute
	PUT(path string, handler interface{}) IAPIRoute
	PATCH(path string, handler interface{}) IAPIRoute
	DELETE(path string, handler interface{}) IAPIRoute
	OPTIONS(path string, handler interface{}) IAPIRoute
	Secure(secure bool)
	AddRoute(path string, handler interface{}, methods ...string) IAPIRoute
	AddWebsocketRoute(path string, handler interface{}, origin func(r *http.Request) bool, methods ...string) IAPIRoute
	Wrap(middlewares ...Middleware)
	Prefix(prefix string)
	Version(version string)
}

type IAPIWebsocketRoute

type IAPIWebsocketRoute interface {
	Wrap(middlewares ...Middleware)
}

type IApplication

type IApplication interface {
	ILogger
	IInclude
	IJwt
	IMiddleware
	Build(port int) IApplication
	Mux() http.Handler
	Di() IContainerBuilder // Agregamos los builders
	Include() IIncludeBuilder
	CSRF() ICSRFBuilder
	JWTBearer() IJWTBuilder
	RateLimiter() IRateLimiterBuilder
	Sanitization() ISanitizationBuilder
	Cors() ICORSBuilder
	HTTPSRedirect() IHTTPSRedirectBuilder
}

type ICORSBuilder

type ICORSBuilder interface {
	Origins(origins ...string) ICORSBuilder
	Methods(methods ...string) ICORSBuilder
	Headers(headers ...string) ICORSBuilder
	Credentials(allow bool) ICORSBuilder
	Apply() IApplication
}

type ICORSConfigurer

type ICORSConfigurer interface {
	AllowedOrigins() []string
	AllowedMethods() []string
	AllowedHeaders() []string
	AllowCredentials() bool
	SetAllowedOrigins([]string)
	SetAllowedMethods([]string)
	SetAllowedHeaders([]string)
	SetAllowCredentials(bool)
}

type ICSRFBuilder

type ICSRFBuilder interface {
	SecretKey(key string) ICSRFBuilder
	TokenLookup(lookup string) ICSRFBuilder
	CookiePath(path string) ICSRFBuilder
	CookieName(name string) ICSRFBuilder
	CookieDomain(domain string) ICSRFBuilder
	CookieSecure(secure bool) ICSRFBuilder
	CookieHTTPOnly(httpOnly bool) ICSRFBuilder
	CookieSameSite(sameSite csrf.SameSiteMode) ICSRFBuilder
	Apply() IApplication
}

type IContainerBuilder

type IContainerBuilder interface {
	// Métodos de Container
	Provide(instance interface{}) IContainerBuilder
	Apply() IApplication
}

type ICsrfConfig

type ICsrfConfig interface {
	SecretKey() []byte
	SetSecretKey([]byte)
	TokenLookup() string
	SetTokenLookup(string)
	CookiePath() string
	SetCookiePath(string)
	CookieName() string
	SetCookieName(string)
	CookieDomain() string
	SetCookieDomain(string)
	CookieSecure() bool
	SetCookieSecure(bool)
	CookieHTTPOnly() bool
	SetCookieHTTPOnly(bool)
	CookieSameSite() csrf.SameSiteMode
	SetCookieSameSite(csrf.SameSiteMode)
}

type IDigContainer

type IDigContainer interface {
	Provide(constructor interface{}, opts ...dig.ProvideOption) error
	Invoke(function interface{}, opts ...dig.InvokeOption) error
}

type IHTTPSRedirectBuilder

type IHTTPSRedirectBuilder interface {
	Apply() IApplication
}

type IInclude

type IInclude interface {
	AddRouter(rtrg func(IAPIRouter))
}

type IIncludeBuilder

type IIncludeBuilder interface {
	Add(rtrg func(IAPIRouter)) IIncludeBuilder
	Apply() IApplication
}

type IJWTBuilder

type IJWTBuilder interface {
	Key(key string) IJWTBuilder
	Algorithms(algorithms []string) IJWTBuilder
	Audience(audience []string) IJWTBuilder
	Issue(issuer []string) IJWTBuilder
	Apply() IApplication
}

type IJWTConfig

type IJWTConfig interface {
	Key() []byte
	Algorithms() []string
	Audience() []string
	Issuer() []string

	SetKey(key string)
	SetAlgorithms(algorithms []string)
	SetAudience(audience []string)
	SetIssuer(issuer []string)
}

type IJwt

type IJwt interface {
	SetJwtConfig(IJWTConfig)
}

type ILogger

type ILogger interface {
	GetLogger() *zap.Logger
}

type IMiddleware

type IMiddleware interface {
	AddMiddleware(Middleware)
}

type IRateLimiter

type IRateLimiter interface {
	Mu() *sync.Mutex
	Requests() map[string]IRateRecord
	MaxRequests() int
	Window() time.Duration
	SetMaxRequests(maxRequests int)
	SetWindow(window time.Duration)
	CleanupExpired()
}

type IRateLimiterBuilder

type IRateLimiterBuilder interface {
	ReqLimit(maxRequests int) IRateLimiterBuilder
	Duration(window time.Duration) IRateLimiterBuilder
	Apply() IApplication
}

type IRateRecord

type IRateRecord interface {
	Count() int
	ResetTime() time.Time
	Increment()
}

type IRequestScope

type IRequestScope interface {
	Request() *http.Request
	Response() http.ResponseWriter
	Protocol() string
	Location() *url.URL
	Pathway() string
	ClientIP() string
	Referral() string

	QueryVal(key string) (string, bool)
	UriParam(key string) (string, bool)
	MetaVal(key string) (string, bool)
	CrumbVal(name string) (*http.Cookie, bool)

	Respond(status int, v interface{})
	Throw(status int, err interface{})
	SetStatus(status int)
	MediaType(mt MediaType)

	SetHeader(key, value string)
	SetCrumb(cookie *http.Cookie)
	SetBaggage(key string, value any)

	SecureChannel() *tls.ConnectionState
	Hostname() string
	RedirectTo(code int, url string)
}

type ISanitizationBuilder

type ISanitizationBuilder interface {
	Apply() IApplication
}

type IStaticFile

type IStaticFile interface {
	ILogger
	AddStaticFile(prefix, dir string)
	StaticFileExists(prefix string) bool
}

type IssueType

type IssueType string
const (
	Missing         IssueType = "missing"          // Falta un campo
	Invalid         IssueType = "invalid"          // Valor no válido
	TypeError       IssueType = "type_error"       // Error de tipo
	Unsupported     IssueType = "unsupported"      // No soportado
	Empty           IssueType = "empty"            // Campo vacío
	Multipart       IssueType = "multipart"        // Error en multipart
	URLEncoded      IssueType = "urlencoded"       // Error en urlencoded
	Syntax          IssueType = "syntax"           // Error de sintaxis
	JSONType        IssueType = "json_type"        // Error en tipo JSON
	Target          IssueType = "target"           // Error en objetivo
	General         IssueType = "general"          // Error genérico
	BodyRead        IssueType = "body_read"        // Error al leer el cuerpo
	InvalidType     IssueType = "invalid_type"     // Tipo no válido
	UnsupportedType IssueType = "unsupported_type" // Tipo no soportado
)

type Location

type Location string

type MediaType

type MediaType string
const (
	ApplicationProblemJSON           = "application/problem+json"
	ApplicationJSON        MediaType = "application/json"
	TextPlain              MediaType = "text/plain"
	TextHTML               MediaType = "text/html"
	ApplicationXML         MediaType = "application/xml"
	OctetStream            MediaType = "application/octet-stream"
	ApplicationForm        MediaType = "application/x-www-form-urlencoded"
	MultipartForm          MediaType = "multipart/form-data"
)

type Middleware

type Middleware func(scope IRequestScope, handler func())

type TagType

type TagType string
const (
	TagQuery   TagType = "Query"
	TagPath    TagType = "Pathway"
	TagHeader  TagType = "Signal"
	TagBody    TagType = "Body"
	TagCookie  TagType = "Crumb"
	TagForm    TagType = "Silk"
	TagService TagType = "Dependency"
	TagContext TagType = "Scope"
)

type UploadFile

type UploadFile *multipart.FileHeader

Jump to

Keyboard shortcuts

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