Documentation ¶
Overview ¶
Package app defines the different pieces of the application, which are all put together in main.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // Config returns an *oauth2.Config configured to reach a OAuth provider. Config() *oauth2.Config }
Client is an interface which provides access to a specific OAuth-based provider.
type Error ¶
Error represents an error in processing, which will be returned from an app.Handler and converted into the appropriate HTTP status code and message.
type Handler ¶
type Handler func(w http.ResponseWriter, r *http.Request) *Error
Handler is an http.Handler which runs the given function and sends the data in *Error, if any, to http.Error, with the proper status code.
type Router ¶
type Router interface { // Route builds an endpoint to the given path. Route(path string) string // Books returns the endpoint which retrieves the user's books. Books() string // Connect returns an endpoint which starts the OAuth flow to authorize this app. Connect() string // Disconnect returns an endpoint which revoke's this application's access to the user's data. Disconnect() string // OAuthCallback returns an endpoint which will be called by the OAuth provider to end the OAuth flow. OAuthCallback() string }
Router is an interface used to determine the endpoints which will be routed to an app.Service's methods.
type Service ¶
type Service interface { // HandleBooks lists the user's books. Works only if the user was previously authenticated and authorized with // HandleConnect. HandleBooks(w http.ResponseWriter, r *http.Request) *Error // HandleConnect starts the OAuth flow, redirecting to the provider. The provider's response should be answered by // HandleOAuthCallback. HandleConnect(w http.ResponseWriter, r *http.Request) *Error // HandleDisconnect revokes this application's access to the user's data. HandleDisconnect(w http.ResponseWriter, r *http.Request) *Error // HandleOAuthCallback should be called by the OAuth provider with its answer to the auth attempt started in // HandleConnect. HandleOAuthCallback(w http.ResponseWriter, r *http.Request) *Error }
Service is an interface which provides app.Handler-compatible methods, which will handle user requests.
func NewService ¶
func NewService() Service
NewService creates a default app.Service with empty implementations.