service

package
v0.0.0-...-3c22c5d Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// available Sizes
	SmallSize  = 50
	MediumSize = 100
	LargeSize  = 150
)
View Source
const (
	TokenName = "AccessToken"
)

Variables

View Source
var (
	// ErrInvalidArgument happens on request without valid arguments
	ErrInvalidArgument = errors.New("invalid Arguments")
	// ErrEmptyCity happens on request without defined city
	ErrEmptyCity = errors.New("bad Request, void City")
)
View Source
var ErrUnauthorized = errors.New("forbidden access")

ErrUnauthorized happens on not authorized

Functions

func NewAuth

func NewAuth(auth Authorizer, pubKey, privKey string, exp time.Duration, appName string) *defaultAuthService

NewAuth instantiates auth service

func NewDefaultStaticAuthorizer

func NewDefaultStaticAuthorizer() *staticAuthorizer

NewDefaultStaticAuthorizer fake authorizer

Types

type AuthService

type AuthService interface {
	// Authorize user credentials and generate token on success
	Authorize(ctx context.Context, user, pass string) (token string, err error)

	// IsValidToken does token validation
	IsValidToken(ctx context.Context, token string) (bool, error)
}

AuthService takes care on authentication features

type Authorizer

type Authorizer interface {
	// ValidCredentials validates user and pass access
	ValidCredentials(user, pass string) (bool, error)
}

Authorizer delegates credential validation

type DefaultService

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

DefaultService defines core service

func New

New instantiates service

func (*DefaultService) GetTopContributors

func (s *DefaultService) GetTopContributors(ctx context.Context, r provider.GithubTopRequest) ([]*provider.Contributor, error)

GetTopContributors returns github top by location

func (*DefaultService) GetTopSearchedLocations

func (s *DefaultService) GetTopSearchedLocations(ctx context.Context, size int) ([]*provider.Location, error)

GetTopSearchedLocations return top Searched Locations

type SearchedLocationsRanking

type SearchedLocationsRanking interface {
	GetTopSearchedLocations(ctx context.Context, size int) ([]*provider.Location, error)
	IncreaseCityScore(ctx context.Context, city string) error
}

SearchedLocationsRanking defines location ranking

Jump to

Keyboard shortcuts

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