api

package
v0.0.0-...-dbd5446 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadUserIP

func ReadUserIP(r *http.Request) string

Types

type API

type API struct {
	BaseGinServer
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(
	log *zap.Logger,
	config *Config,
	shortyService *service.ShortyService,
	qrSvc *service.QRCodeService,
) *API

func (*API) Run

func (a *API) Run()

type AuthenticationMiddleware

type AuthenticationMiddleware struct {
	// contains filtered or unexported fields
}

func NewAuthenticationMiddleware

func NewAuthenticationMiddleware(token string) *AuthenticationMiddleware

func (*AuthenticationMiddleware) Authenticated

func (a *AuthenticationMiddleware) Authenticated(c *gin.Context)

type BaseGinServer

type BaseGinServer struct{}

func (*BaseGinServer) PushHandlerWithGroup

func (*BaseGinServer) PushHandlerWithGroup(h HTTPHandler, rg *gin.RouterGroup)

type Config

type Config struct {
	Port           int    `env:"API_PORT"`
	Token          string `env:"AUTH_TOKEN"`
	HostName       string `env:"HOST_NAME"`
	UnknownPage    string `env:"UNKNOWN_PAGE"`
	DBUsername     string `env:"DB_USERNAME"`
	DBPassword     string `env:"DB_PASSWORD"`
	DBName         string `env:"DB_NAME"`
	DBHost         string `env:"DB_URL"`
	DBPort         int    `env:"DB_PORT"`
	SSLMode        string `env:"SSL_MODE"`
	PublicIDLength int    `env:"PUBLIC_ID_LENGTH"`
}

func (*Config) GetDatabaseConfig

func (c *Config) GetDatabaseConfig() *database.Config

type HTTPHandler

type HTTPHandler interface {
	Routes(rg *gin.RouterGroup)
	Group() *string
}

func NewPreviewHandler

func NewPreviewHandler(qrSvc *service.QRCodeService) HTTPHandler

func NewShortenerHandler

func NewShortenerHandler(shortySvc *service.ShortyService) HTTPHandler

func NewURLHandler

func NewURLHandler(unknownPage string, svc *service.ShortyService) HTTPHandler

type Server

type Server interface {
	PushHandlerWithGroup(h HTTPHandler, rg *gin.RouterGroup)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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