services

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 14 Imported by: 2

Documentation

Overview

Package services defines services capable of linking a key to a user.

Index

Constants

View Source
const GithubID = "github"

GithubID is id for github.

View Source
const TwitterID = "twitter"

TwitterID is the id for twitter.

Variables

View Source
var Echo = &echo{}

Echo service.

View Source
var Github = &github{}

Github service.

View Source
var HTTPS = &https{}

HTTPS service.

View Source
var KeysPub = &keyspub{}

KeysPub uses keys.pub user cache instead of the service directly.

View Source
var Proxy = &proxy{}

Proxy uses keys.pub user cache instead of the service directly.

View Source
var Reddit = &reddit{}

Reddit service.

View Source
var Twitter = &twitter{
	bearerToken: os.Getenv("TWITTER_BEARER_TOKEN"),
}

Twitter ..

Functions

func Request

func Request(ctx context.Context, client http.Client, urs string, headers []http.Header) (user.Status, []byte, error)

Request resource.

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

func UpdateResult

func UpdateResult(ctx context.Context, service Service, result *user.Result, client http.Client, now time.Time)

UpdateResult updates a user.Result. The result.Status is success (StatusOK) or type of failure. If a failure, result.Err has the error message.

func Verify

func Verify(ctx context.Context, service Service, client http.Client, usr *user.User) *user.Result

Verify a user. The result.Status is success (StatusOK) or type of failure. If a failure, result.Err has the error message.

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 {
	// Request resource with client.
	Request(ctx context.Context, client http.Client, usr *user.User) (user.Status, []byte, error)

	// Verify content.
	Verify(ctx context.Context, b []byte, usr *user.User) (user.Status, *Verified, error)
}

Service describes a user service.

func Lookup

func Lookup(service string) (Service, error)

Lookup service by name.

type Verified

type Verified struct {
	Statement string
	Timestamp int64
	Proxied   bool
}

Verified results.

Jump to

Keyboard shortcuts

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