link

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package link defines services capable of linking keys to users.

Index

Constants

This section is empty.

Variables

View Source
var Echo = &echo{}

Echo service (for testing).

View Source
var Github = &github{}

Github service.

View Source
var HTTPS = &https{}

HTTPS service.

View Source
var Reddit = &reddit{}

Reddit service.

View Source
var Twitter = &twitter{}

Twitter service.

Functions

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

Types

type ContextLogger

type ContextLogger interface {
	Debugf(ctx context.Context, format string, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})
	Warningf(ctx context.Context, format string, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
}

ContextLogger interface used in this package with request context.

func NewContextLogger

func NewContextLogger(lev LogLevel) ContextLogger

NewContextLogger ...

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

type Service

type Service interface {
	// Identifier of the service, e.g. "github", "twitter".
	ID() string

	// Normalize the service user name.
	// For example, on Twitter, "@username" becomes "username" or "Gabriel"
	// becomes "gabriel".
	NormalizeName(name string) string

	// ValidateName validates the service user name.
	ValidateName(name string) error

	// NormalizeURLString normalizes an url string.
	NormalizeURLString(name string, urs string) (string, error)

	// ValidateURLString validates the URL string and returns where to find the
	// signed statement.
	// For example, on reddit ".json" is appended.
	ValidateURLString(name string, urs string) (string, error)

	// CheckContent returns data with statement.
	// For Twitter, Github there is no check since the user owns the URL location.
	// For Reddit, we need to verify the listing, author and subreddit and return only the listing text.
	CheckContent(name string, b []byte) ([]byte, error)
}

Service describes a user service.

func NewService

func NewService(service string) (Service, error)

NewService returns a service by name.

Jump to

Keyboard shortcuts

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