Documentation ¶
Index ¶
- type Mock
- func (m *Mock) GetLongURL(ctx context.Context, shortURL string) (string, error)
- func (m *Mock) GetShortURL(ctx context.Context, longURL string) (string, error)
- func (m *Mock) GetStats(ctx context.Context, shortURL string) (int, error)
- func (m *Mock) SaveShortURL(ctx context.Context, longURL, shortURL string) error
- type PostgreSQL
- func (p *PostgreSQL) GetLongURL(ctx context.Context, shortURL string) (string, error)
- func (p *PostgreSQL) GetShortURL(ctx context.Context, longURL string) (string, error)
- func (p *PostgreSQL) GetStats(ctx context.Context, shortURL string) (int, error)
- func (p *PostgreSQL) SaveShortURL(ctx context.Context, shortURL, longURL string) error
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mock ¶
type Mock struct { GetShortURLFunc func(ctx context.Context, longURL string) (string, error) GetLongURLFunc func(ctx context.Context, shortURL string) (string, error) GetStatsFunc func(ctx context.Context, shortURL string) (int, error) SaveShortURLFunc func(ctx context.Context, longURL, shortURL string) error }
func (*Mock) GetLongURL ¶
func (*Mock) GetShortURL ¶
type PostgreSQL ¶
type PostgreSQL struct {
// contains filtered or unexported fields
}
PostgreSQL is a repository that implements the Repository interface.
func NewPostgreSQL ¶
func NewPostgreSQL(logger *zap.Logger, dbConn db) *PostgreSQL
NewPostgreSQL creates a new PostgreSQL repository.
func (*PostgreSQL) GetLongURL ¶
GetLongURL returns the long URL for a given short URL.
func (*PostgreSQL) GetShortURL ¶
GetShortURL returns the short URL for a given long URL.
func (*PostgreSQL) SaveShortURL ¶
func (p *PostgreSQL) SaveShortURL(ctx context.Context, shortURL, longURL string) error
SaveShortURL saves a short URL to the database.
type Repository ¶
type Repository interface { GetShortURL(ctx context.Context, longURL string) (string, error) GetLongURL(ctx context.Context, shortURL string) (string, error) GetStats(ctx context.Context, shortURL string) (int, error) SaveShortURL(ctx context.Context, longURL, shortURL string) error }
Repository is an interface that defines the methods that a repository should implement.
Click to show internal directories.
Click to hide internal directories.