decorators

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 1 Imported by: 0

README

Deco Framework 🚀

Go Gopher Artist
The Go Gopher decorator, crafting elegant APIs with simple annotations! ✨

A modern, annotation-driven Go web framework built on top of Gin. Write web APIs using simple @ annotations and let deco handle the heavy lifting - automatic route registration, middleware injection, validation, caching, rate limiting, security, and more!

✨ Why Deco?

  • 🚀 Zero Boilerplate: Define routes and middleware with simple annotations
  • 🛡️ Built-in Security: Automatic protection for internal endpoints
  • 🔄 API Gateway: Service discovery, load balancing, circuit breakers
  • 📊 Observability: Metrics, tracing, and monitoring out of the box
  • ⚡ Production Ready: Optimized builds with validation and minification

🚀 Quick Start

# Install CLI
go install github.com/RodolfoBonis/deco/cmd/deco@latest

# Initialize project
deco init

# Create your first handler
# @Route("GET", "/health")
# func HealthCheck(c *gin.Context) {
#     c.JSON(200, gin.H{"status": "healthy"})
# }

# Generate and run
deco generate
go run main.go

🎯 Key Features

🔒 Security
// Automatic internal endpoint protection
r := deco.Default()

// Custom security configuration
securityConfig := &deco.SecurityConfig{
    AllowPrivateNetworks: true,
    AllowLocalhost: true,
}
r := deco.DefaultWithSecurity(securityConfig)
🔄 API Gateway
// @Route("GET", "/api/users/:id")
// @Proxy(service="user-service", discovery="consul")
func GetUserProxy(c *gin.Context) {
    // Automatically forwards to user-service
}
💾 Caching & Rate Limiting
// @Route("GET", "/users/:id")
// @Cache(ttl="5m")
// @RateLimit(limit=100, window="1m")
func GetUser(c *gin.Context) {
    // Response cached for 5 minutes, 100 requests per minute
}

📚 Documentation

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📚 Documentation

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Overview

Package decorators fornece um framework baseado em anotações para Gin

Index

Constants

This section is empty.

Variables

View Source
var (
	// Funções de registro
	RegisterRoute         = decorators.RegisterRoute
	RegisterRouteWithMeta = decorators.RegisterRouteWithMeta
	RegisterGroup         = decorators.RegisterGroup
	Default               = decorators.Default
	DefaultWithSecurity   = decorators.DefaultWithSecurity
	GetRoutes             = decorators.GetRoutes
	GetGroups             = decorators.GetGroups

	// Funções de markers
	RegisterMarker = decorators.RegisterMarker
	GetMarkers     = decorators.GetMarkers

	// Hooks
	RegisterParserHook    = decorators.RegisterParserHook
	RegisterGeneratorHook = decorators.RegisterGeneratorHook

	// Funções de middleware
	CreateAuthMiddleware           = decorators.CreateAuthMiddleware
	CreateCacheMiddleware          = decorators.CreateCacheMiddleware
	CreateRateLimitMiddleware      = decorators.CreateRateLimitMiddleware
	CreateMetricsMiddleware        = decorators.CreateMetricsMiddleware
	CreateCORSMiddleware           = decorators.CreateCORSMiddleware
	CreateWebSocketMiddleware      = decorators.CreateWebSocketMiddleware
	CreateWebSocketStatsMiddleware = decorators.CreateWebSocketStatsMiddleware
	CreateProxyMiddleware          = decorators.CreateProxyMiddleware
	CreateSecurityMiddleware       = decorators.CreateSecurityMiddleware

	// Funções de segurança
	SecureInternalEndpoints = decorators.SecureInternalEndpoints
	AllowLocalhostOnly      = decorators.AllowLocalhostOnly
	AllowPrivateNetworks    = decorators.AllowPrivateNetworks
	AllowSpecificNetworks   = decorators.AllowSpecificNetworks
	AllowSpecificIPs        = decorators.AllowSpecificIPs
	DefaultSecurityConfig   = decorators.DefaultSecurityConfig

	// Funções de geração
	GenerateInitFile = decorators.GenerateInitFile

	// Funções de documentação
	DocsHandler            = decorators.DocsHandler
	DocsJSONHandler        = decorators.DocsJSONHandler
	OpenAPIJSONHandler     = decorators.OpenAPIJSONHandler
	OpenAPIYAMLHandler     = decorators.OpenAPIYAMLHandler
	SwaggerUIHandler       = decorators.SwaggerUIHandler
	SwaggerRedirectHandler = decorators.SwaggerRedirectHandler

	// WebSocket functions
	RegisterWebSocketHandler         = decorators.RegisterWebSocketHandler
	RegisterDefaultWebSocketHandlers = decorators.RegisterDefaultWebSocketHandlers
	GetWebSocketHub                  = decorators.GetWebSocketHub
	WebSocketHandlerWrapper          = decorators.WebSocketHandlerWrapper
)

Re-exportar funções principais

Functions

This section is empty.

Types

type GenData

type GenData = decorators.GenData

GenData dados para templates de geração

type GeneratorHook

type GeneratorHook = decorators.GeneratorHook

GeneratorHook represents a hook for custom generation logic

type GroupInfo

type GroupInfo = decorators.GroupInfo

GroupInfo informações de grupos

type MarkerConfig

type MarkerConfig = decorators.MarkerConfig

MarkerConfig configuration of a marker personalizado

type MarkerInstance

type MarkerInstance = decorators.MarkerInstance

MarkerInstance instância de um marker encontrado

type MiddlewareInfo

type MiddlewareInfo = decorators.MiddlewareInfo

MiddlewareInfo information about middlewares

type ParameterInfo

type ParameterInfo = decorators.ParameterInfo

ParameterInfo informações de parâmetros

type ParserHook

type ParserHook = decorators.ParserHook

Hooks ParserHook is an alias for decorators.ParserHook. Represents a hook for custom parsing logic.

type RouteEntry

type RouteEntry = decorators.RouteEntry

RouteEntry representa uma rota registrada

type RouteMeta

type RouteMeta = decorators.RouteMeta

RouteMeta contém metadata extraída dos comentários

type SecurityConfig added in v0.10.0

type SecurityConfig = decorators.SecurityConfig

Security types

Directories

Path Synopsis
cmd
deco command
security command
pkg

Jump to

Keyboard shortcuts

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