urlgenerator

package
v0.0.0-...-d12243e Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockRedisClient

type MockRedisClient struct{}

MockRedisClient represents a mock Redis client for testing

func NewMockRedisClient

func NewMockRedisClient() *MockRedisClient

func (*MockRedisClient) RedirectToURL

func (m *MockRedisClient) RedirectToURL(ctx context.Context, shortURL string) (string, error)

func (*MockRedisClient) ShortenURL

func (m *MockRedisClient) ShortenURL(ctx context.Context, destination string) (string, error)

type RedisClient

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

RedisClient represents a Redis client connection

func NewRedisClient

func NewRedisClient() *RedisClient

NewRedisClient creates a new instance of RedisClient

func (*RedisClient) RedirectToURL

func (rc *RedisClient) RedirectToURL(ctx context.Context, shortURL string) (string, error)

RedirectToURL retrieves the original URL from the short URL in Redis

func (*RedisClient) SaveUrl

func (rc *RedisClient) SaveUrl(ctx context.Context, shortUrl string, originalUrl string) error

func (*RedisClient) ShortenURL

func (rc *RedisClient) ShortenURL(ctx context.Context, url string) (string, error)

ShortenURL generates a short URL and stores it in Redis

type RedisClientProvider

type RedisClientProvider interface {
	ShortenURL(ctx context.Context, url string) (string, error)
	RedirectToURL(ctx context.Context, shortURL string) (string, error)
}

Jump to

Keyboard shortcuts

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