service

package
v0.0.0-...-d3d161b Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

type Mock struct {
	CreateShortURLFunc    func(ctx context.Context, longURL string) (string, error)
	RedirectToLongURLFunc func(ctx context.Context, shortURL string) (string, error)
	GetStatsFunc          func(ctx context.Context, shortURL string) (int, error)
}

func (*Mock) CreateShortURL

func (m *Mock) CreateShortURL(ctx context.Context, longURL string) (string, error)

func (*Mock) GetStats

func (m *Mock) GetStats(ctx context.Context, shortURL string) (int, error)

func (*Mock) RedirectToLongURL

func (m *Mock) RedirectToLongURL(ctx context.Context, shortURL string) (string, error)

type Service

type Service interface {
	CreateShortURL(ctx context.Context, longURL string) (string, error)
	RedirectToLongURL(ctx context.Context, shortURL string) (string, error)
	GetStats(ctx context.Context, shortURL string) (int, error)
}

Service is an interface that defines the methods that a service should implement.

type ServiceDefault

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

func NewServiceDefault

func NewServiceDefault(logger *zap.Logger, appHost string, repo repository.Repository) *ServiceDefault

func (*ServiceDefault) CreateShortURL

func (s *ServiceDefault) CreateShortURL(ctx context.Context, longURL string) (string, error)

func (*ServiceDefault) GetStats

func (s *ServiceDefault) GetStats(ctx context.Context, shortURL string) (int, error)

func (*ServiceDefault) RedirectToLongURL

func (s *ServiceDefault) RedirectToLongURL(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