Documentation ¶
Index ¶
Constants ¶
View Source
const CacheTypeDisabled = "disabled"
View Source
const CacheTypeInMemory = "in-memory"
View Source
const CacheTypeRedis = "redis"
View Source
const StorageTypeFile = "file"
View Source
const StorageTypePostgres = "postgres"
Variables ¶
View Source
var MetricRequestsTotal = promauto.NewSummaryVec( prometheus.SummaryOpts{ Namespace: "shorter", Subsystem: "http", Name: "requests", Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.01}, }, []string{"status"}, )
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { Config Config Logger *utils.Logger Validator Validator Links LinksCollectionInterface Background *utils.Background }
func (*Application) Serve ¶
func (app *Application) Serve() error
type Config ¶
type Config struct { ProjectHost string `env:"PROJECT_HOST" env-default:""` ProjectPort int `env:"PROJECT_PORT" env-default:"80"` ProjectStorageType string `env:"PROJECT_STORAGE_TYPE" env-default:"file"` FileAsync bool `env:"FILE_ASYNC" env-default:"false"` DbDSN string `env:"DB_DSN" env-default:"postgres://go:pa55word@localhost:5432/short_links?sslmode=disable"` DbMaxOpenConns int `env:"DB_MAX_OPEN_CONNS" env-default:"25"` DbMaxIdleConns int `env:"DB_MAX_IDLE_CONNS" env-default:"25"` DbMaxIdleTime string `env:"DB_MAX_OPEN_TIME" env-default:"15m"` DbTimeout int `env:"DATABASE_TIMEOUT" env-default:"1"` CacheType string `env:"CACHE_TYPE" env-default:"disabled"` CacheCapacity int `env:"CACHE_CAPACITY" env-default:"10"` CacheRedisDSN string `env:"CACHE_REDIS_DSN" env-default:"redis://localhost:6379/0"` LimiterEnabled bool `env:"LIMITER_ENABLED" env-default:"true"` LimiterRPS int `env:"LIMITER_RPS" env-default:"2"` LimiterBurst int `env:"LIMITER_BURST" env-default:"4"` }
type ReaderFunc ¶
type ReaderFunc func(http.ResponseWriter, *http.Request, interface{}) error
func (ReaderFunc) Run ¶
func (f ReaderFunc) Run(w http.ResponseWriter, r *http.Request, destination interface{}) error
type Validator ¶
type Validator struct { KeyMaxLength int // contains filtered or unexported fields }
func NewValidator ¶
type WriterFunc ¶
func (WriterFunc) Run ¶
func (f WriterFunc) Run(w http.ResponseWriter, r *http.Request, data interface{}) ([]byte, error)
Click to show internal directories.
Click to hide internal directories.