shorten

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLinkNotExist .
	ErrLinkNotExist = errors.New("sorry, the link you accessed doesn't exist on our service. Please keep in mind that our shortened links are case sensitive and may contain letters and numbers")
)

Functions

func Get

func Get(ctx context.Context, key string, redisClient *redis.Client, bf *bloomfilter.BloomFilter) (longurl string, err error)

Get url by key.

func Insert

func Insert(ctx context.Context, rawurl, domain string, redisClient *redis.Client, bf *bloomfilter.BloomFilter) (string, error)

Insert url.

Types

type Server

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

Server can be installed to serve.

func NewServer

func NewServer(cfg *config.Config, scfg ServerConfig) *Server

NewServer creates as new Server with the given dependencies.

func (*Server) Install

func (s *Server) Install() http.Handler

Install registers server routes.

type ServerConfig

type ServerConfig struct {
	RedisClient *redis.Client
	BloomFilter *bloomfilter.BloomFilter
	StaticPath  string
}

ServerConfig contains everything needed by a server.

type Shorten

type Shorten struct {
	Key      string `json:"key,omitempty"`
	Link     string `json:"link,omitempty"`
	LongURL  string `json:"long_url,omitempty"`
	CreateAt int64  `json:"create_at,omitempty"`
}

Shorten url info.

Jump to

Keyboard shortcuts

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