handler

package
v0.0.0-...-9f1c163 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisClient

type RedisClient interface {
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	Incr(ctx context.Context, key string) *redis.IntCmd
}

type URLHandler

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

func NewURLHandler

func NewURLHandler(rdb RedisClient) *URLHandler

func (*URLHandler) GenerateShortURL

func (h *URLHandler) GenerateShortURL(w http.ResponseWriter, r *http.Request)

GenerateShortURL creates a short URL and stores it in the handler's map

func (*URLHandler) IncrementAccessCount

func (s *URLHandler) IncrementAccessCount(ctx context.Context, shortURL string) error

func (*URLHandler) RedirectShortURL

func (h *URLHandler) RedirectShortURL(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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