storage

package
v0.0.0-...-c7c103a Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package storage wraps access to the persistence layer.

Package storage is a wrapper package designed to simplify utilization of the MongoDB Go driver. It creates an interface that facilitates access to Get, Save, and Info functions related to the database storage and retrieval of shortened urls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInfo

func GetInfo() ([]models.Shortener, error)

GetInfo retrieves a slice of shortened urls from the database

func GetURL

func GetURL(code string) (string, error)

GetURL retrieves a URL from the database based on the encoded version of that url.

func SaveURL

func SaveURL(url string) (string, error)

SaveURL accepts a single url parameter and returns a string containing the encoded version of the url that has been saved in the database.

func SetStorage

func SetStorage(s Storage)

SetStorage is a function that accepts a single parameter of type Storage and assigns the repository type to the received variable param

func URLExists

func URLExists(url string) (bool, error)

URLExists checks if a string matches the url of a saved, shortened URL.

Types

type Storage

type Storage interface {
	GetURL(code string) (string, error)
	SaveURL(url string) (string, error)
	GetInfo() ([]models.Shortener, error)
	URLExists(code string) (bool, error)
}

Storage is an interface which provides details on the utilization of Get, Save and Info routines

Directories

Path Synopsis
Package mongodb is an example MongoDB client implementation written in Go This package extends a Repository metaphor which wraps access methods for the MongoDB database and collections that are used in the example.
Package mongodb is an example MongoDB client implementation written in Go This package extends a Repository metaphor which wraps access methods for the MongoDB database and collections that are used in the example.

Jump to

Keyboard shortcuts

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