controllers

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Setup

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

Setup for handlers package.

func New

func New(
	model *model.Conn,
	redis *redis.Client,
	validator *validator.Validate,
	logger *logger.Logger,
) *Setup

New initiates the setup.

func (*Setup) AuthMiddleware

func (s *Setup) AuthMiddleware(next http.Handler) http.Handler

AuthMiddleware checks if the request contains Bearer Token on the headers and if it is valid.

func (*Setup) AuthUser

func (s *Setup) AuthUser(w http.ResponseWriter, r *http.Request)

AuthUser authenticates the user.

func (*Setup) CheckCache

func (s *Setup) CheckCache(ctx context.Context, key string, dest interface{}) (bool, error)

CheckCache checks if the given key exists in cache.

func (*Setup) CheckPasswordHash

func (s *Setup) CheckPasswordHash(password, hash string) bool

CheckPasswordHash checks if the given passwords matches.

func (*Setup) CreateGenre

func (s *Setup) CreateGenre(w http.ResponseWriter, r *http.Request)

CreateGenre creates a new genre.

func (*Setup) CreateKeyword

func (s *Setup) CreateKeyword(w http.ResponseWriter, r *http.Request)

CreateKeyword creates a new keyword.

func (*Setup) CreateRecommendation

func (s *Setup) CreateRecommendation(w http.ResponseWriter, r *http.Request)

CreateRecommendation creates a new recommendation.

func (*Setup) CreateRecommendationItem

func (s *Setup) CreateRecommendationItem(w http.ResponseWriter, r *http.Request)

CreateRecommendationItem creates a new recommendation item.

func (*Setup) CreateSource

func (s *Setup) CreateSource(w http.ResponseWriter, r *http.Request)

CreateSource creates a new source.

func (*Setup) CreateUser

func (s *Setup) CreateUser(w http.ResponseWriter, r *http.Request)

CreateUser creates a new user.

func (*Setup) DeleteGenre

func (s *Setup) DeleteGenre(w http.ResponseWriter, r *http.Request)

DeleteGenre deletes a genre.

func (*Setup) DeleteKeyword

func (s *Setup) DeleteKeyword(w http.ResponseWriter, r *http.Request)

DeleteKeyword deletes a keyword.

func (*Setup) DeleteRecommendation

func (s *Setup) DeleteRecommendation(w http.ResponseWriter, r *http.Request)

DeleteRecommendation deletes a recommendation.

func (*Setup) DeleteRecommendationItem

func (s *Setup) DeleteRecommendationItem(w http.ResponseWriter, r *http.Request)

DeleteRecommendationItem deletes a recommendation item.

func (*Setup) DeleteSource

func (s *Setup) DeleteSource(w http.ResponseWriter, r *http.Request)

DeleteSource deletes a source.

func (*Setup) DeleteUser

func (s *Setup) DeleteUser(w http.ResponseWriter, r *http.Request)

DeleteUser deletes a user.

func (*Setup) GenerateCacheKey

func (s *Setup) GenerateCacheKey(params url.Values, key string) string

GenerateCacheKey generates a cache key base on the given key and returns a string.

func (*Setup) GenerateToken

func (s *Setup) GenerateToken(info *model.Auth) (string, error)

GenerateToken generates a new JWT Token.

func (*Setup) GetGenre

func (s *Setup) GetGenre(w http.ResponseWriter, r *http.Request)

GetGenre gets a genre by ID.

func (*Setup) GetGenres

func (s *Setup) GetGenres(w http.ResponseWriter, r *http.Request)

GetGenres gets all genres.

func (*Setup) GetKeyword

func (s *Setup) GetKeyword(w http.ResponseWriter, r *http.Request)

GetKeyword gets a keyword by ID.

func (*Setup) GetKeywords

func (s *Setup) GetKeywords(w http.ResponseWriter, r *http.Request)

GetKeywords gets all keywords.

func (*Setup) GetRecommendation

func (s *Setup) GetRecommendation(w http.ResponseWriter, r *http.Request)

GetRecommendation gets a recommendation by ID.

func (*Setup) GetRecommendationGenres

func (s *Setup) GetRecommendationGenres(w http.ResponseWriter, r *http.Request)

GetRecommendationGenres gets all genres of a specific recommendation.

func (*Setup) GetRecommendationItem

func (s *Setup) GetRecommendationItem(w http.ResponseWriter, r *http.Request)

GetRecommendationItem gets a recommendation item by ID.

func (*Setup) GetRecommendationItemSources

func (s *Setup) GetRecommendationItemSources(w http.ResponseWriter, r *http.Request)

GetRecommendationItemSources gets all sources of a specific recommendation item.

func (*Setup) GetRecommendationItems

func (s *Setup) GetRecommendationItems(w http.ResponseWriter, r *http.Request)

GetRecommendationItems gets all recommendation items.

func (*Setup) GetRecommendationKeywords

func (s *Setup) GetRecommendationKeywords(w http.ResponseWriter, r *http.Request)

GetRecommendationKeywords gets all keywords of a specific recommendation.

func (*Setup) GetRecommendations

func (s *Setup) GetRecommendations(w http.ResponseWriter, r *http.Request)

GetRecommendations gets all recommendations.

func (*Setup) GetRecommendationsAdmin

func (s *Setup) GetRecommendationsAdmin(w http.ResponseWriter, r *http.Request)

GetRecommendationsAdmin get the latest recommendations without status filter.

func (*Setup) GetSource

func (s *Setup) GetSource(w http.ResponseWriter, r *http.Request)

GetSource gets a source by ID.

func (*Setup) GetSources

func (s *Setup) GetSources(w http.ResponseWriter, r *http.Request)

GetSources gets all sources.

func (*Setup) GetUser

func (s *Setup) GetUser(w http.ResponseWriter, r *http.Request)

GetUser gets a user by ID.

func (*Setup) GetUsers

func (s *Setup) GetUsers(w http.ResponseWriter, r *http.Request)

GetUsers get all users.

func (*Setup) HashPassword

func (s *Setup) HashPassword(password string, cost int) (string, error)

HashPassword encrypts a given password using bcrypt algorithm.

func (*Setup) IDParser

func (s *Setup) IDParser(sid string) (int64, error)

IDParser converts the given ID to int64.

func (*Setup) LoggerMiddleware added in v1.9.1

func (s *Setup) LoggerMiddleware(next http.Handler) http.Handler

LoggerMiddleware logs the details of all requests.

func (*Setup) MarshalBinary

func (s *Setup) MarshalBinary(d interface{}) ([]byte, error)

MarshalBinary is a implementation of BinaryMarshaler interface.

func (*Setup) PageParser

func (s *Setup) PageParser(params url.Values) (int, error)

PageParser checks if page string exists in the given URL params. If exists, it will be parsed to int and returned. If some error occurs, the default value will be returned.

Default value: 1.

func (*Setup) RateLimit added in v1.9.2

func (s *Setup) RateLimit(next http.Handler) http.Handler

RateLimit middleware handles the rate limiting.

func (*Setup) RemoveCache

func (s *Setup) RemoveCache(ctx context.Context, key string) error

RemoveCache removes the given key from the cache.

func (*Setup) SearchGenre

func (s *Setup) SearchGenre(w http.ResponseWriter, r *http.Request)

SearchGenre searches for genres.

func (*Setup) SearchKeyword

func (s *Setup) SearchKeyword(w http.ResponseWriter, r *http.Request)

SearchKeyword searches for keywords.

func (*Setup) SearchRecommendation

func (s *Setup) SearchRecommendation(w http.ResponseWriter, r *http.Request)

SearchRecommendation searches for recommendations.

func (*Setup) SearchSource

func (s *Setup) SearchSource(w http.ResponseWriter, r *http.Request)

SearchSource searches for sources.

func (*Setup) SearchUser

func (s *Setup) SearchUser(w http.ResponseWriter, r *http.Request)

SearchUser searches for users.

func (*Setup) SetCache

func (s *Setup) SetCache(ctx context.Context, key string, dest interface{}) error

SetCache sets the given key in cache.

func (*Setup) ToJSON

func (s *Setup) ToJSON(
	w http.ResponseWriter,
	httpStatus int,
	dest interface{},
)

ToJSON returns a JSON response.

func (*Setup) UnmarshalBinary

func (s *Setup) UnmarshalBinary(d []byte, v interface{}) error

UnmarshalBinary is a implementation of BinaryUnmarshaler interface.

func (*Setup) UpdateGenre

func (s *Setup) UpdateGenre(w http.ResponseWriter, r *http.Request)

UpdateGenre updates a genre.

func (*Setup) UpdateKeyword

func (s *Setup) UpdateKeyword(w http.ResponseWriter, r *http.Request)

UpdateKeyword updates a keyword.

func (*Setup) UpdateRecommendation

func (s *Setup) UpdateRecommendation(w http.ResponseWriter, r *http.Request)

UpdateRecommendation updates a recommendation.

func (*Setup) UpdateRecommendationItem

func (s *Setup) UpdateRecommendationItem(w http.ResponseWriter, r *http.Request)

UpdateRecommendationItem updates a recommendation item.

func (*Setup) UpdateSource

func (s *Setup) UpdateSource(w http.ResponseWriter, r *http.Request)

UpdateSource updates a source.

func (*Setup) UpdateUser

func (s *Setup) UpdateUser(w http.ResponseWriter, r *http.Request)

UpdateUser updates a user.

Jump to

Keyboard shortcuts

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