url

package
v0.0.0-...-ff4c1db Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLongURLEmpty = errors.New("long URL cannot be empty")
View Source
var ErrShortURLEmpty = errors.New("short URL cannot be empty")

Functions

func NewURLService

func NewURLService(urlStore model.IURLStore) model.IURLService

Types

type GetURLByLong

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

func NewGetURLByLong

func NewGetURLByLong(long string) (*GetURLByLong, error)

func (*GetURLByLong) Execute

func (c *GetURLByLong) Execute(ctx context.Context, s model.IURLService) (*model.URL, error)

type GetURLByShort

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

func NewGetURLByShort

func NewGetURLByShort(short string) (*GetURLByShort, error)

func (*GetURLByShort) Execute

func (c *GetURLByShort) Execute(ctx context.Context, s model.IURLService) (*model.URL, error)

type PSQLStore

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

func NewPSQLStore

func NewPSQLStore(dbpool *pgxpool.Pool) *PSQLStore

func (*PSQLStore) CreateURL

func (s *PSQLStore) CreateURL(ctx context.Context, url *model.URL) error

CreateURL inserts a new url into the PSQL database

func (*PSQLStore) QueryURL

func (s *PSQLStore) QueryURL(ctx context.Context, id model.URLID) (*model.URL, error)

QueryURL queries the database for a URL with the given ID.

func (*PSQLStore) QueryURLByLong

func (s *PSQLStore) QueryURLByLong(ctx context.Context, long model.LongURL) (*model.URL, error)

QueryURLByLong queries the database for a URL with the given long URL.

func (*PSQLStore) QueryURLByShort

func (s *PSQLStore) QueryURLByShort(ctx context.Context, short model.ShortURL) (*model.URL, error)

QueryURLByShort queries the database for a URL with the given short URL.

type ShortenURL

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

func NewShortenURL

func NewShortenURL(long string) (*ShortenURL, error)

func (*ShortenURL) Execute

func (c *ShortenURL) Execute(ctx context.Context, s model.IURLService) (*model.URL, error)

type URLService

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

func (*URLService) GetURLByLong

func (s *URLService) GetURLByLong(ctx context.Context, long model.LongURL) (*model.URL, error)

GetURLByLong gets the URL object associated with the given long URL.

func (*URLService) GetURLByShort

func (s *URLService) GetURLByShort(ctx context.Context, short model.ShortURL) (*model.URL, error)

GetURLByShort gets the URL object associated with the given short URL.

func (*URLService) InsertURL

func (s *URLService) InsertURL(ctx context.Context, url *model.URL) error

func (*URLService) ShortenURL

func (s *URLService) ShortenURL(ctx context.Context, long model.LongURL) (model.ShortURL, error)

ShortenURL is a function that generates a URL object for a given URL.

Jump to

Keyboard shortcuts

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