service

package
v0.0.0-...-31d4dac Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package service provides the business logic for URL shortener

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Shortener

type Shortener interface {
	Shorten(longURL string) (string, error)
	GetLongURL(slug string) (string, error)
	GetURLVisits(slug string, unit string) (entity.Metric, error)
	LogURLVisit(slug string, date string) error
}

type Store

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

func New

func New(s store.StoreInterface) *Store

func (*Store) GetLongURL

func (s *Store) GetLongURL(slug string) (string, error)

GetLongURL retrieves the long URL from the store

func (*Store) GetURLVisits

func (s *Store) GetURLVisits(slug string, unit string) (entity.Metric, error)

GetURLVisits quries the store for URL visits

func (*Store) LogURLVisit

func (s *Store) LogURLVisit(slug string, date string) error

LogURLVisit inserts URL visit event in the store

func (*Store) Shorten

func (s *Store) Shorten(longURL string) (string, error)

Shorten creates a slug for the short URL and persists it in the store

Jump to

Keyboard shortcuts

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