shortener

package
v0.0.2-beta Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package shortener contains business-logic for url shortening.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorURLNotFound is returned if given URL is not found in storage.
	ErrorURLNotFound = errors.New("url not found")
)

Functions

This section is empty.

Types

type Service

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

Service provides functionality for URL storing and retrieving.

func NewService

func NewService() Service

NewService returns new service instance with in-memory storage.

func (Service) RetrieveURL

func (s Service) RetrieveURL(short string) (long string, err error)

RetrieveURL returns full url by given short key. Returns ErrorURLNotFound if nothing exists.

func (Service) ShortenURL

func (s Service) ShortenURL(long string) (short string, err error)

ShortenURL accepts full URL and returns corresponding short key.

Jump to

Keyboard shortcuts

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