handlers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeserializingReq = errors.New("Error reading request body")

ErrDeserializingReq Error deserializing request body

View Source
var ErrInvalidReqBody error = errors.New("Error validating request body")

ErrInvalidReqBody error validating request body

View Source
var ErrInvalidURL error = errors.New("invalid URL")

ErrInvalidURL URL given to be shortened is not valid

View Source
var ErrShortenedNotExist = errors.New("shortened URL does not exist")

ErrShortenedNotExist shortened URL does not exist

Functions

This section is empty.

Types

type GenericError

type GenericError struct {
	Message string `json:"message"`
}

GenericError is a generic error message returned by a server

type Urls

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

Urls is a http.Handler

func NewUrls

func NewUrls(l *log.Logger, urlList data.Urls) *Urls

NewUrls creates a Urls handler

func (*Urls) AddURL

func (u *Urls) AddURL(rw http.ResponseWriter, r *http.Request)

AddURL adds a new URL struct in urlList

func (*Urls) GetURL

func (u *Urls) GetURL(rw http.ResponseWriter, r *http.Request)

GetURL redirects shortened URL to original URL

func (*Urls) MiddlewareValidateURL

func (u *Urls) MiddlewareValidateURL(next http.Handler) http.Handler

MiddlewareValidateURL validates the url in the request and calls next if ok

type ValidationError

type ValidationError struct {
	Messages []string `json:"messages"`
}

ValidationError is a collection of validation error messages

Jump to

Keyboard shortcuts

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