server

package
v0.0.0-...-a757527 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentUser

func CurrentUser(ctx context.Context) (interface{}, error)

CurrentUser gets the current user or errors

func RunServer

func RunServer(config Config)

RunServer runs a server with the specified config

func SetCurrentUserFn

func SetCurrentUserFn(ctx context.Context, fn func(ctx context.Context) (interface{}, error)) context.Context

SetCurrentUserFn sets the context with the given current user resolver, it shouldn't be used directly and is only exported for testing

func Tx

func Tx(ctx context.Context) *sqlx.Tx

Tx MUST be called only after using the transaction middleware

Types

type ClaimsOrToken

type ClaimsOrToken struct {
	Claims *verifier.StandardClaims
	Token  string
}

ClaimsOrToken represents either claims found or and API token found

type Config

type Config struct {
	Migrations     *rice.Box
	Assets         *rice.Box
	HostPort       string
	DatabaseURL    string
	ClientID       string
	ClientSecret   string
	BaseURL        string
	SecretKey      string
	Domains        []string
	Setup          func(config *SetupConfig)
	GetCurrentUser func(ctx context.Context, claimsOrToken *ClaimsOrToken) (interface{}, error)
	OnFirstUser    func(ctx context.Context, claims *verifier.StandardClaims) error
	OnLogin        func(ctx context.Context, claims *verifier.StandardClaims) error
}

Config provides the configuration for the server

type SetupConfig

type SetupConfig struct {
	Render  common.Renderer
	Router  chi.Router
	DB      *sqlx.DB
	Logger  zerolog.Logger
	Handler *oauth.Handler
}

SetupConfig provides the configuration for the setup phase

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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