handler

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: AGPL-3.0 Imports: 57 Imported by: 0

Documentation

Overview

Package handler contains all of the HTTP handlers for Emissary. This maps loosely to the "Controllers/Gateways/Presenters" concept in the "Clean Architecture" design pattern (https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html). Handlers are wired directly to routes by the main server process, and are the only entry points for web-based access to Emissary.

Each handler's first task is to determine which domain is being requested. This is done by calling the server.Factory and passing it the current request context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActorUsername added in v0.7.0

func ActorUsername(actor streams.Document) string

ActorUsername returns a human-readable username for an Actor

func Blocked added in v0.7.0

func Blocked(ctx echo.Context) error

func GetAdmin

func GetAdmin(factoryManager *server.Factory) echo.HandlerFunc

GetAdmin handles GET requests

func GetChangePassword added in v0.6.0

func GetChangePassword(serverFactory *server.Factory) echo.HandlerFunc

func GetCloseWindow added in v0.7.0

func GetCloseWindow(ctx echo.Context) error

GetCloseWindow is an HTTP handler that returns HTML to close the current window. It is used as a callback URL for outbound intents that use true pop-up windows.

func GetCompleteRegistration added in v0.7.0

func GetCompleteRegistration(ctx *steranko.Context, factory *domain.Factory, domain *model.Domain, registration *model.Registration) error

PostRegister generates an echo.HandlerFunc that handles POST /register requests

func GetDomainAttachment added in v0.7.0

func GetDomainAttachment(factoryManager *server.Factory) echo.HandlerFunc

func GetEmptyCollection added in v0.7.0

func GetEmptyCollection(serverFactory *server.Factory) echo.HandlerFunc

GetEmptyCollection returns an empty collection

func GetFavicon

func GetFavicon(factoryManager *server.Factory) echo.HandlerFunc

GetFavicon returns the default favicon for this server

func GetFollowingTunnel

func GetFollowingTunnel(context echo.Context) error

GetFollowingTunnel is a hack to work around the restrictions from SameSite cookies. If the user is coming from another site, their Authentication cookies won't be sent because we use SameSite=Strict. But they WILL be sent from this redirect. So, it's another hop, but it's still better for users.

func GetGiphyWidget

func GetGiphyWidget(serverFactory *server.Factory) echo.HandlerFunc

func GetHostMeta added in v0.6.0

func GetHostMeta(serverFactory *server.Factory) echo.HandlerFunc

func GetHostMetaJSON added in v0.6.0

func GetHostMetaJSON(serverFactory *server.Factory) echo.HandlerFunc

func GetInbox added in v0.6.0

func GetInbox(serverFactory *server.Factory) echo.HandlerFunc

GetInbox handles GET requests

func GetIntentInfo added in v0.7.0

func GetIntentInfo(ctx *steranko.Context, factory *domain.Factory) error

func GetIntent_Create added in v0.7.0

func GetIntent_Create(ctx *steranko.Context, factory *domain.Factory, user *model.User) error

func GetIntent_Dislike added in v0.7.0

func GetIntent_Dislike(ctx *steranko.Context, factory *domain.Factory, user *model.User) error

func GetIntent_Follow added in v0.7.0

func GetIntent_Follow(ctx *steranko.Context, factory *domain.Factory, user *model.User) error

func GetIntent_Like added in v0.7.0

func GetIntent_Like(ctx *steranko.Context, factory *domain.Factory, user *model.User) error

func GetNodeInfo

func GetNodeInfo(serverFactory *server.Factory) echo.HandlerFunc

GetNodeInfo returns the discovery links for nodeInfo endpoints http://nodeinfo.diaspora.software/protocol.html http://nodeinfo.diaspora.software/schema.html

func GetNodeInfo20 added in v0.6.0

func GetNodeInfo20(serverFactory *server.Factory) echo.HandlerFunc

GetNodeInfo20 returns the nodeInfo 2.0 document for this server http://nodeinfo.diaspora.software/ns/schema/2.0 http://nodeinfo.diaspora.software/docson/index.html#/ns/schema/2.0#$$expand

func GetNodeInfo21 added in v0.6.0

func GetNodeInfo21(serverFactory *server.Factory) echo.HandlerFunc

GetNodeInfo21 returns the nodeInfo 2.1 document for this server http://nodeinfo.diaspora.software/ns/schema/2.1 http://nodeinfo.diaspora.software/docson/index.html#/ns/schema/2.1#$$expand

func GetOAuth

func GetOAuth(fm *server.Factory) echo.HandlerFunc

GetOAuth looks up the OAuth provider and forwards to the appropriate endpoint

func GetOAuthAuthorization added in v0.6.0

func GetOAuthAuthorization(serverFactory *server.Factory) echo.HandlerFunc

func GetOAuthCallback

func GetOAuthCallback(fm *server.Factory) echo.HandlerFunc

func GetOEmbed

func GetOEmbed(ctx *steranko.Context, factory *domain.Factory) error

GetOEmbed will provide an OEmbed service to be used exclusively by websites on this domain.

func GetOutboundIntent added in v0.7.0

func GetOutboundIntent(ctx *steranko.Context, factory *domain.Factory) error

GetOutboundIntent translates an intent+account into a URL where we forward the user to complete the intent on their home server.

func GetOutbox added in v0.6.0

func GetOutbox(serverFactory *server.Factory) echo.HandlerFunc

GetOutbox handles GET requests

func GetProfileIcon added in v0.7.0

func GetProfileIcon(serverFactory *server.Factory) echo.HandlerFunc

func GetProfileImage added in v0.7.0

func GetProfileImage(serverFactory *server.Factory) echo.HandlerFunc

func GetQRCode

func GetQRCode(fm *server.Factory) echo.HandlerFunc

Get builds the Stream HTML to the context

func GetRegister

func GetRegister(ctx *steranko.Context, factory *domain.Factory, domain *model.Domain, registration *model.Registration) error

GetRegister generates an echo.HandlerFunc that handles GET /register requests

func GetResetCode

func GetResetCode(serverFactory *server.Factory) echo.HandlerFunc

GetResetCode displays a form (authenticated by the reset code) for resetting a user's password

func GetResetPassword

func GetResetPassword(serverFactory *server.Factory) echo.HandlerFunc

func GetSearchTagAttachment added in v0.7.0

func GetSearchTagAttachment(ctx *steranko.Context, factory *domain.Factory) error

func GetServiceActor added in v0.7.0

func GetServiceActor(serverFactory *server.Factory) echo.HandlerFunc

func GetSignIn

func GetSignIn(serverFactory *server.Factory) echo.HandlerFunc

GetSignIn generates an echo.HandlerFunc that handles GET /signin requests

func GetSingleSignOn added in v0.7.0

func GetSingleSignOn(ctx *steranko.Context, factory *domain.Factory, domain *model.Domain) error

func GetStartup added in v0.6.0

func GetStartup(serverFactory *server.Factory) echo.HandlerFunc

func GetStream

func GetStream(serverFactory *server.Factory) echo.HandlerFunc

GetStream handles GET requests with the default action. This handler also responds to JSON-LD requests

func GetStreamAttachment added in v0.7.0

func GetStreamAttachment(factoryManager *server.Factory) echo.HandlerFunc

func GetStreamWithAction added in v0.6.0

func GetStreamWithAction(serverFactory *server.Factory) echo.HandlerFunc

GetStreamWithAction handles GET requests with a specified action

func GetTemplateBundle

func GetTemplateBundle(serverFactory *server.Factory) echo.HandlerFunc

func GetTemplateResource added in v0.6.0

func GetTemplateResource(serverFactory *server.Factory) echo.HandlerFunc

func GetThemeBundle

func GetThemeBundle(serverFactory *server.Factory) echo.HandlerFunc

func GetThemeResource added in v0.6.0

func GetThemeResource(serverFactory *server.Factory) echo.HandlerFunc

func GetUserAttachment added in v0.7.0

func GetUserAttachment(factoryManager *server.Factory) echo.HandlerFunc

func GetWebSubClient

func GetWebSubClient(serverFactory *server.Factory) echo.HandlerFunc

GetWebSubClient is called by an external WebSub server to confirm a subscription request.

func GetWebfinger

func GetWebfinger(fm *server.Factory) echo.HandlerFunc

GetWebfinger returns public webfinger information for a designated user. https://webfinger.net WebFinger data based on https://docs.joinmastodon.org/spec/webfinger/

func GetWidgetBundle

func GetWidgetBundle(serverFactory *server.Factory) echo.HandlerFunc

func GetWidgetResource added in v0.6.0

func GetWidgetResource(serverFactory *server.Factory) echo.HandlerFunc

func IndexAllStreams added in v0.7.0

func IndexAllStreams(ctx *steranko.Context, factory *domain.Factory) error

IndexAllStreams is a handler function that triggers the IndexAllStreams queue task. It can only be called by an authenticated administrator.

func IndexAllUsers added in v0.7.0

func IndexAllUsers(ctx *steranko.Context, factory *domain.Factory) error

IndexAllUsers is a handler function that triggers the IndexAllUsers queue task. It can only be called by an authenticated administrator.

func Mastodon added in v0.6.0

func Mastodon(serverFactory *server.Factory) toot.API[model.Authorization]

func ModelService_Form

func ModelService_Form(ctx echo.Context, modelService service.ModelService)

func ModelService_RenderTemplate

func ModelService_RenderTemplate(serverFactory *server.Factory, ctx echo.Context, serviceName string, builder builder.Builder, templateName string) (string, error)

TODO: Remove?

func NotFound added in v0.7.0

func NotFound(ctx echo.Context) error

NotFound returns the default favicon for this server

func OAuthRedirect

func OAuthRedirect(factory *server.Factory) echo.HandlerFunc

func PostAdmin

func PostAdmin(factoryManager *server.Factory) echo.HandlerFunc

PostAdmin handles POST/DELETE requests

func PostEmailFollower added in v0.7.0

func PostEmailFollower(serverFactory *server.Factory) echo.HandlerFunc

func PostInbox added in v0.6.0

func PostInbox(serverFactory *server.Factory) echo.HandlerFunc

PostInbox handles POST/DELETE requests

func PostIntent_Create added in v0.7.0

func PostIntent_Create(ctx *steranko.Context, factory *domain.Factory, user *model.User) error

func PostIntent_Dislike added in v0.7.0

func PostIntent_Dislike(ctx *steranko.Context, factory *domain.Factory, user *model.User) error

func PostIntent_Follow added in v0.7.0

func PostIntent_Follow(ctx *steranko.Context, factory *domain.Factory, user *model.User) error

func PostIntent_Like added in v0.7.0

func PostIntent_Like(ctx *steranko.Context, factory *domain.Factory, user *model.User) error

func PostMasquerade added in v0.7.0

func PostMasquerade(serverFactory *server.Factory) echo.HandlerFunc

func PostOAuthAuthorization added in v0.6.0

func PostOAuthAuthorization(serverFactory *server.Factory) echo.HandlerFunc

func PostOAuthRevoke added in v0.6.0

func PostOAuthRevoke(serverFactory *server.Factory) echo.HandlerFunc

func PostOAuthToken added in v0.6.0

func PostOAuthToken(serverFactory *server.Factory) echo.HandlerFunc

func PostOStatusDiscover

func PostOStatusDiscover(serverFactory *server.Factory) echo.HandlerFunc

PostOStatusDiscover looks up a user's profile using oStatus discovery. If successful, it returns a redirect to the user's follow-request page. If unsuccessful, it returns a 200 with an English-language error message.

func PostOutbox added in v0.6.0

func PostOutbox(serverFactory *server.Factory) echo.HandlerFunc

PostOutbox handles POST/DELETE requests

func PostRegister

func PostRegister(ctx *steranko.Context, factory *domain.Factory, domain *model.Domain, registration *model.Registration) error

func PostResetCode

func PostResetCode(serverFactory *server.Factory) echo.HandlerFunc

func PostResetPassword

func PostResetPassword(serverFactory *server.Factory) echo.HandlerFunc

func PostServiceActor_Inbox added in v0.7.0

func PostServiceActor_Inbox(serverFactory *server.Factory) echo.HandlerFunc

PostServiceActor_Inbox does not take any actions, but only logs the request IF logger is in Debug or Trace mode.

func PostSignIn

func PostSignIn(serverFactory *server.Factory) echo.HandlerFunc

PostSignIn generates an echo.HandlerFunc that handles POST /signin requests

func PostSignOut

func PostSignOut(serverFactory *server.Factory) echo.HandlerFunc

PostSignOut generates an echo.HandlerFunc that handles POST /signout requests

func PostStartup added in v0.6.0

func PostStartup(serverFactory *server.Factory) echo.HandlerFunc

func PostStreamWithAction added in v0.6.0

func PostStreamWithAction(serverFactory *server.Factory) echo.HandlerFunc

PostStreamWithAction handles POST requests with a specified action

func PostUpdateRegistration added in v0.7.0

func PostUpdateRegistration(ctx *steranko.Context, factory *domain.Factory, domain *model.Domain, registration *model.Registration) error

PostUpdateRegistration generates an echo.HandlerFunc that handles POST /register requests

func PostWebMention

func PostWebMention(serverFactory *server.Factory) echo.HandlerFunc

func PostWebSubClient

func PostWebSubClient(serverFactory *server.Factory) echo.HandlerFunc

PostWebSubClient is called by an external WebSub server to notify us of a change.

func ServerSentEvent

func ServerSentEvent(factoryManager *server.Factory) echo.HandlerFunc

ServerSentEvent generates an echo.HandlerFunc that listens for requests for SSE following.

func SetupDomainDelete

func SetupDomainDelete(factory *server.Factory) echo.HandlerFunc

SetupDomainDelete deletes a domain from the configuration

func SetupDomainGet

func SetupDomainGet(factory *server.Factory) echo.HandlerFunc

SetupDomainGet displays the form for creating/editing a domain.

func SetupDomainPost

func SetupDomainPost(factory *server.Factory) echo.HandlerFunc

SetupDomainPost updates/creates a domain

func SetupDomainSigninPost

func SetupDomainSigninPost(fm *server.Factory) echo.HandlerFunc

SetupDomainSigninPost signs you in to the requested domain as an administrator

func SetupDomainUserDelete

func SetupDomainUserDelete(serverFactory *server.Factory, templates *template.Template) echo.HandlerFunc

func SetupDomainUserInvite

func SetupDomainUserInvite(serverFactory *server.Factory, templates *template.Template) echo.HandlerFunc

func SetupDomainUserPost

func SetupDomainUserPost(serverFactory *server.Factory, templates *template.Template) echo.HandlerFunc

func SetupDomainUsersGet

func SetupDomainUsersGet(serverFactory *server.Factory, templates *template.Template) echo.HandlerFunc

func SetupOAuthGet

func SetupOAuthGet(factory *server.Factory, templates *template.Template) echo.HandlerFunc

func SetupOAuthList

func SetupOAuthList(factory *server.Factory, templates *template.Template) echo.HandlerFunc

func SetupOAuthPost

func SetupOAuthPost(factory *server.Factory, templates *template.Template) echo.HandlerFunc

func SetupPageGet

func SetupPageGet(factory *server.Factory, templates *template.Template, templateID string) echo.HandlerFunc

SetupPageGet generates simple template pages for the setup server, based on the Templates and ID provided.

func SetupServerGet

func SetupServerGet(factory *server.Factory) echo.HandlerFunc

SetupServerGet generates a form for the setup app.

func SetupServerPost

func SetupServerPost(factory *server.Factory) echo.HandlerFunc

SetupServerPost saves the form data to the config file.

func TBD

func TBD(ctx echo.Context) error

TBD represents a placeholder handler that will be removed before release.

func WithAuthenticatedUser added in v0.7.0

func WithAuthenticatedUser(serverFactory *server.Factory, fn WithFunc1[model.User]) echo.HandlerFunc

WithAuthenticatedUser handles boilerplate code for requests that require a signed-in user

func WithDomain added in v0.7.0

func WithDomain(serverFactory *server.Factory, fn WithFunc1[model.Domain]) echo.HandlerFunc

WithDomain handles boilerplate code for requests that load a domain object

func WithFactory added in v0.7.0

func WithFactory(serverFactory *server.Factory, fn WithFunc0) echo.HandlerFunc

WithFactory handles boilerplate code for requests that require only the domain Factory

func WithRegistration added in v0.7.0

func WithRegistration(serverFactory *server.Factory, fn WithFunc2[model.Domain, model.Registration]) echo.HandlerFunc

WithRegistration handles boilerplate code for requests that use a Registration object

func WithStream added in v0.7.0

func WithStream(serverFactory *server.Factory, fn WithFunc1[model.Stream]) echo.HandlerFunc

WithStream handles boilerplate code for requests that load a stream

func WithUser added in v0.7.0

func WithUser(serverFactory *server.Factory, fn WithFunc1[model.User]) echo.HandlerFunc

WithUser handles boilerplate code for requests that load a user by username or ID

Types

type AsWriteCloser

type AsWriteCloser struct {
	io.Writer
}

AsWriteCloser is a hacky kludge that lets us use an io.Writer as an io.WriteCloser

func (AsWriteCloser) Close

func (writeCloser AsWriteCloser) Close() error

type WithFunc0 added in v0.7.0

type WithFunc0 func(ctx *steranko.Context, factory *domain.Factory) error

WithFunc0 is a function signature for a continuation function that requires only the domain Factory

type WithFunc1 added in v0.7.0

type WithFunc1[T any] func(ctx *steranko.Context, factory *domain.Factory, value *T) error

WithFunc1 is a function signature for a continuation function that requires the domain Factory and a single value

type WithFunc2 added in v0.7.0

type WithFunc2[T any, U any] func(ctx *steranko.Context, factory *domain.Factory, value *T, value2 *U) error

WithFunc2 is a function signature for a continuation function that requires the domain Factory and two values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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