Documentation
¶
Index ¶
- Constants
- func JSAdminBlock(deleteTitleText, deleteConfirmText, editTitleText *language.LocalizedString) string
- func JSOpenModal(selector string) string
- func JSTooltip() string
- type ContextKey
- type Module
- func (m *Module) AdminBlockExportCSVGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) AdminBlockExportGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) AdminBlockExportJSONGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) AdminBlockGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) AdminBlockPostHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) AdminHomeGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) AdminHomePostHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) AdminInstanceGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) BlocksGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) CallbackOauthGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) ForwardToHomeHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) HomeGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) LogGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) LoginGetHandler(w nethttp.ResponseWriter, r *nethttp.Request)
- func (m *Module) LoginPostHandler(w nethttp.ResponseWriter, r *nethttp.Request)
- func (m *Module) LogoutGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) Middleware(next http.Handler) http.Handler
- func (m *Module) MiddlewareRequireAdmin(next http.Handler) http.Handler
- func (*Module) Name() string
- func (m *Module) Route(s *http.Server) error
- func (m *Module) SetServer(s *ihttp.Server)
- func (m *Module) SettingsGetHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) SettingsPostHandler(w http.ResponseWriter, r *http.Request)
- func (m *Module) WrapInMiddlewares(h http.Handler) http.Handler
- type SessionKey
Constants ¶
const ( // COAnonymous is an anonymous cross origin. COAnonymous = "anonymous" // ActionAdd is the value for an add action. ActionAdd = "add" // ActionDelete is the value for a delete action. ActionDelete = "delete" // ActionEdit is the value for an edit action. ActionEdit = "edit" // ActionImport is the value for an import action. ActionImport = "import" // CSVHeaderBlockSubdomains is the value for a Block Subdomains csv header. CSVHeaderBlockSubdomains = "Block Subdomains" // CSVHeaderDomain is the value for a Domain csv header. CSVHeaderDomain = "Domain" // CSVHeaderObfuscatedDomain is the value for an Obfuscated Domain csv header. CSVHeaderObfuscatedDomain = "Obfuscated Domain" // FormAction is the key for an action form field. FormAction = "action" // FormDomain is the key for a domain form field. FormDomain = "domain" // FormFile is the key for a file form field. FormFile = "file" // FormHomeBody is the key for a home body form field. FormHomeBody = "home-body" // FormObfuscatedDomain is the key for a domain form field. FormObfuscatedDomain = "obfuscated-domain" // FormSubdomain is the key for a subdomain form field. FormSubdomain = "subdomain" // FormTelegramChatID is the key for a chat ID form field. FormTelegramChatID = "telegram-chat-id" // FormTelegramChatIDType is the key for a chat ID type form field. FormTelegramChatIDType = "telegram-chat-id-type" // FormTelegramEnabled is the key for a telegram enabled form field. FormTelegramEnabled = "telegram-enabled" // FormTelegramToken is the key for a telegram token form field. FormTelegramToken = "telegram-token" // FormToken is the key for a token form field. FormToken = "token" FormValueUsername = "username" FormValueChatID = "chat-id" )
const SessionMaxAge = 30 * 24 * time.Hour // 30 days
Variables ¶
This section is empty.
Functions ¶
func JSAdminBlock ¶
func JSAdminBlock(deleteTitleText, deleteConfirmText, editTitleText *language.LocalizedString) string
func JSOpenModal ¶
Types ¶
type ContextKey ¶
type ContextKey int
ContextKey is a key used in http request contexts.
const ( // ContextKeySession is the persistent session. ContextKeySession ContextKey = iota // ContextKeyLocalizer is the language localizer. ContextKeyLocalizer // ContextKeyLanguage is the language. ContextKeyLanguage // ContextKeyAccount is the logged in user's account. ContextKeyAccount // ContextKeyOauthNonce is the oauth nonce. ContextKeyOauthNonce )
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module contains a webapp module for the web server. Implements web.Module.
func New ¶
func New( ctx context.Context, d db.DB, f *fedi.Module, lMod *language.Module, l logic.Logic, mc metrics.Collector, r redis.UniversalClient, run runner.Runner, tokz *token.Tokenizer, ) (*Module, error)
New returns a new webapp module.
func (*Module) AdminBlockExportCSVGetHandler ¶
func (m *Module) AdminBlockExportCSVGetHandler(w http.ResponseWriter, r *http.Request)
AdminBlockExportCSVGetHandler serves the home page.
func (*Module) AdminBlockExportGetHandler ¶
func (m *Module) AdminBlockExportGetHandler(w http.ResponseWriter, r *http.Request)
AdminBlockExportGetHandler serves the home page.
func (*Module) AdminBlockExportJSONGetHandler ¶
func (m *Module) AdminBlockExportJSONGetHandler(w http.ResponseWriter, r *http.Request)
AdminBlockExportJSONGetHandler serves the home page.
func (*Module) AdminBlockGetHandler ¶
func (m *Module) AdminBlockGetHandler(w http.ResponseWriter, r *http.Request)
AdminBlockGetHandler serves the home page.
func (*Module) AdminBlockPostHandler ¶
func (m *Module) AdminBlockPostHandler(w http.ResponseWriter, r *http.Request)
AdminBlockPostHandler serves the home page.
func (*Module) AdminHomeGetHandler ¶
func (m *Module) AdminHomeGetHandler(w http.ResponseWriter, r *http.Request)
AdminHomeGetHandler serves the admin home page.
func (*Module) AdminHomePostHandler ¶
func (m *Module) AdminHomePostHandler(w http.ResponseWriter, r *http.Request)
AdminHomePostHandler handles the admin home page form.
func (*Module) AdminInstanceGetHandler ¶
func (m *Module) AdminInstanceGetHandler(w http.ResponseWriter, r *http.Request)
AdminInstanceGetHandler serves the home page.
func (*Module) BlocksGetHandler ¶ added in v0.2.0
func (m *Module) BlocksGetHandler(w http.ResponseWriter, r *http.Request)
BlocksGetHandler serves the blocks page.
func (*Module) CallbackOauthGetHandler ¶
func (m *Module) CallbackOauthGetHandler(w http.ResponseWriter, r *http.Request)
CallbackOauthGetHandler handles an oauth callback.
func (*Module) ForwardToHomeHandler ¶
func (m *Module) ForwardToHomeHandler(w http.ResponseWriter, r *http.Request)
ForwardToHomeHandler serves a home forwarder.
func (*Module) HomeGetHandler ¶
func (m *Module) HomeGetHandler(w http.ResponseWriter, r *http.Request)
HomeGetHandler serves the home page.
func (*Module) LogGetHandler ¶ added in v0.3.0
func (m *Module) LogGetHandler(w http.ResponseWriter, r *http.Request)
LogGetHandler serves the logs page.
func (*Module) LoginGetHandler ¶
func (m *Module) LoginGetHandler(w nethttp.ResponseWriter, r *nethttp.Request)
LoginGetHandler serves the login page.
func (*Module) LoginPostHandler ¶
func (m *Module) LoginPostHandler(w nethttp.ResponseWriter, r *nethttp.Request)
LoginPostHandler attempts a login.
func (*Module) LogoutGetHandler ¶
func (m *Module) LogoutGetHandler(w http.ResponseWriter, r *http.Request)
LogoutGetHandler logs a user out.
func (*Module) Middleware ¶
Middleware runs on every http request.
func (*Module) MiddlewareRequireAdmin ¶
MiddlewareRequireAdmin will redirect a user to login page if user not in context and will return unauthorized for a non admin user.
func (*Module) SettingsGetHandler ¶ added in v0.2.0
func (m *Module) SettingsGetHandler(w http.ResponseWriter, r *http.Request)
SettingsGetHandler serves the home page.
func (*Module) SettingsPostHandler ¶ added in v0.2.0
func (m *Module) SettingsPostHandler(w http.ResponseWriter, r *http.Request)
SettingsPostHandler serves the home page.
type SessionKey ¶
type SessionKey int
SessionKey is a key used for storing data in a web session.
const ( // SessionKeyAccountID contains the id of the currently logged-in user. SessionKeyAccountID SessionKey = iota // SessionKeyLoginRedirect contains the url to be redirected too after logging in. SessionKeyLoginRedirect )
Source Files
¶
- admin_block.go
- admin_block_add.go
- admin_block_delete.go
- admin_block_edit.go
- admin_block_export.go
- admin_block_import.go
- admin_home.go
- admin_home_form.go
- admin_instance.go
- blocks.go
- callback.go
- const.go
- context_key.go
- error.go
- home.go
- js.go
- logger.go
- login.go
- logout.go
- logs.go
- middleware.go
- permission.go
- puny.go
- redirect.go
- route.go
- session_key.go
- settings.go
- settings_form.go
- template.go
- util.go
- validator.go
- webapp.go