webapp

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: GPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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

func JSOpenModal(selector string) string

func JSTooltip

func JSTooltip() string

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

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

func (m *Module) Middleware(next http.Handler) http.Handler

Middleware runs on every http request.

func (*Module) MiddlewareRequireAdmin

func (m *Module) MiddlewareRequireAdmin(next http.Handler) http.Handler

MiddlewareRequireAdmin will redirect a user to login page if user not in context and will return unauthorized for a non admin user.

func (*Module) Name

func (*Module) Name() string

Name return the module name.

func (*Module) Route

func (m *Module) Route(s *http.Server) error

Route attaches routes to the web server.

func (*Module) SetServer

func (m *Module) SetServer(s *ihttp.Server)

SetServer adds a reference to the server to the module.

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.

func (*Module) WrapInMiddlewares

func (m *Module) WrapInMiddlewares(h http.Handler) http.Handler

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
)

Jump to

Keyboard shortcuts

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