webapp

package
v0.0.0-...-eb23ef5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (

	// COAnonymous is an anonymous cross origin.
	COAnonymous = "anonymous"

	// ActionAddTeamMember is the value for an add team member action.
	ActionAddTeamMember = "add-team-member"
	// ActionDeleteTeamMember is the value for a delete team member action.
	ActionDeleteTeamMember = "delete-team-member"
	// ActionDisableS3CDN is the value for a disable s3 cdn team member action.
	ActionDisableS3CDN = "disable-s3-cdn"
	// ActionEnableS3CDN is the value for an enable s3 cdn team member action.
	ActionEnableS3CDN = "enable-s3-cdn"
	// ActionTransferOwnership is the value for a delete team member action.
	ActionTransferOwnership = "transfer-ownership"

	// 	FormAccount is the key for am account form field.
	FormAccount = "account"
	// FormAction is the key for an action form field.
	FormAction = "action"
	// FormToken is the key for a token form field.
	FormToken = "token"
)
View Source
const SessionMaxAge = 30 * 24 * time.Hour // 30 days

Variables

This section is empty.

Functions

func ForwardTo

func ForwardTo(f string) func(w http.ResponseWriter, r *http.Request)

ForwardTo creates a forwarder.

func JSAdminInstanceView

func JSAdminInstanceView(deleteTitleText, deleteConfirmText, transferOwnershipTitleText, transferOwnershipConfirmText *language.LocalizedString) 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

func New(
	ctx context.Context,
	d db.DB,
	lMod *language.Module,
	logicMod *logic.Logic,
	r redis.UniversalClient,
	tokz *token.Tokenizer,
) (*Module, error)

New returns a new webapp module.

func (*Module) AdminAccountGetHandler

func (m *Module) AdminAccountGetHandler(w http.ResponseWriter, r *http.Request)

AdminAccountGetHandler serves the home page.

func (*Module) AdminAutocompleteAccountGetHandler

func (m *Module) AdminAutocompleteAccountGetHandler(w http.ResponseWriter, r *http.Request)

AdminAutocompleteAccountGetHandler 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) AdminInstanceGetHandler

func (m *Module) AdminInstanceGetHandler(w http.ResponseWriter, r *http.Request)

AdminInstanceGetHandler serves the home page.

func (*Module) AdminInstanceViewGetHandler

func (m *Module) AdminInstanceViewGetHandler(w http.ResponseWriter, r *http.Request)

AdminInstanceViewGetHandler serves the instance info page.

func (*Module) AdminInstanceViewPostHandler

func (m *Module) AdminInstanceViewPostHandler(w http.ResponseWriter, r *http.Request)

AdminInstanceViewPostHandler serves the home page.

func (*Module) CallbackOauthGetHandler

func (m *Module) CallbackOauthGetHandler(w http.ResponseWriter, r *http.Request)

CallbackOauthGetHandler handles an oauth callback.

func (*Module) HomeGetHandler

func (m *Module) HomeGetHandler(w http.ResponseWriter, r *http.Request)

HomeGetHandler serves the home page.

func (*Module) LoginGetHandler

func (m *Module) LoginGetHandler(w http.ResponseWriter, r *http.Request)

LoginGetHandler serves the login page.

func (*Module) LoginPostHandler

func (m *Module) LoginPostHandler(w http.ResponseWriter, r *http.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 *ihttp.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

func (m *Module) SettingsGetHandler(w http.ResponseWriter, r *http.Request)

SettingsGetHandler 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