2018-02-15 01:11:59 +02:00
|
|
|
// Package defaults houses default implementations for the very many
|
|
|
|
// interfaces that authboss has. It's a goal of the defaults package
|
|
|
|
// to provide the core where authboss implements the shell.
|
|
|
|
//
|
|
|
|
// It's simultaneously supposed to be possible to take as many or
|
|
|
|
// as few of these implementations as you desire, allowing you to
|
|
|
|
// reimplement where necessary, but reuse where possible.
|
2018-02-05 07:24:55 +02:00
|
|
|
package defaults
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/volatiletech/authboss"
|
|
|
|
)
|
|
|
|
|
2018-02-16 19:55:45 +02:00
|
|
|
// SetCore creates instances of all the default pieces
|
|
|
|
// with the exception of ViewRenderer which should be already set
|
|
|
|
// before calling this method.
|
2018-05-09 16:59:19 +02:00
|
|
|
func SetCore(config *authboss.Config, readJSON, useUsername bool) {
|
2018-02-05 07:24:55 +02:00
|
|
|
logger := NewLogger(os.Stdout)
|
|
|
|
|
|
|
|
config.Core.Router = NewRouter()
|
2018-02-16 19:55:45 +02:00
|
|
|
config.Core.ErrorHandler = NewErrorHandler(logger)
|
|
|
|
config.Core.Responder = NewResponder(config.Core.ViewRenderer)
|
|
|
|
config.Core.Redirector = NewRedirector(config.Core.ViewRenderer, RedirectFormValueName)
|
2018-05-09 16:59:19 +02:00
|
|
|
config.Core.BodyReader = NewHTTPBodyReader(readJSON, useUsername)
|
2018-02-05 07:24:55 +02:00
|
|
|
config.Core.Mailer = NewLogMailer(os.Stdout)
|
|
|
|
config.Core.Logger = logger
|
|
|
|
}
|