web

package
v0.0.0-...-21abf39 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Anonymous string      = ""
	HelperKey ContextType = 7

	// openssl rand -hex 32
	// ruby -rsecurerandom -e "puts SecureRandom.hex(32)"
	SessionStore = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY")))
)
View Source
var (
	AssetLookups = []assetLookup{
		localeFiles.ReadFile,
	}
)

Functions

func Auth

func Auth(store oauth2.TokenStore) func(http.Handler) http.Handler

func Cors

func Cors(pass http.Handler) http.Handler

func DebugLog

func DebugLog(pass http.Handler) http.Handler

func EstablishContext

func EstablishContext(svr sparq.Server) func(http.Handler) http.Handler

func HttpError

func HttpError(w http.ResponseWriter, err error, code int)

func IsLoggedIn

func IsLoggedIn(r *http.Request) string

func MultipartTestForm

func MultipartTestForm(filefield string, filename string, extrafields map[string]string) (bytes.Buffer, *multipart.Writer, error)

func NewTestServer

func NewTestServer(t *testing.T, name string) (sparq.Server, func())

func RegisterPages

func RegisterPages(pages ...string)

func Render

func Render(w http.ResponseWriter, r *http.Request, page string, custom any)

func RequireLogin

func RequireLogin(fn http.HandlerFunc) http.HandlerFunc

func RootRouter

func RootRouter(s sparq.Server) *mux.Router

Types

type ContextType

type ContextType int32

type PageData

type PageData struct {
	Locale string
	Custom any
	// contains filtered or unexported fields
}

func (*PageData) CurrentAccount

func (pd *PageData) CurrentAccount() *model.Account

func (*PageData) Session

func (pd *PageData) Session() *sessions.Session

func (*PageData) T

func (pd *PageData) T(text string) string

type SqliteOauthStore

type SqliteOauthStore struct {
	DB *sqlx.DB
}

func IntegrateOauth

func IntegrateOauth(s sparq.Server, root *mux.Router) *SqliteOauthStore

func (*SqliteOauthStore) Create

func (scs *SqliteOauthStore) Create(ctx context.Context, info oauth2.TokenInfo) error

func (*SqliteOauthStore) Delete

func (scs *SqliteOauthStore) Delete(ctx context.Context, id string) error

func (*SqliteOauthStore) GetByAccess

func (scs *SqliteOauthStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error)

func (*SqliteOauthStore) GetByCode

func (scs *SqliteOauthStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error)

func (*SqliteOauthStore) GetByID

func (scs *SqliteOauthStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error)

func (*SqliteOauthStore) GetByRefresh

func (scs *SqliteOauthStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error)

func (*SqliteOauthStore) RemoveByAccess

func (scs *SqliteOauthStore) RemoveByAccess(ctx context.Context, access string) error

func (*SqliteOauthStore) RemoveByCode

func (scs *SqliteOauthStore) RemoveByCode(ctx context.Context, code string) error

func (*SqliteOauthStore) RemoveByRefresh

func (scs *SqliteOauthStore) RemoveByRefresh(ctx context.Context, refresh string) error

func (*SqliteOauthStore) Set

func (scs *SqliteOauthStore) Set(ctx context.Context, id string, cli oauth2.ClientInfo) error

type WebCtx

type WebCtx struct {
	BearerCode    string
	LangCode      string
	CurrentUserID string
	// contains filtered or unexported fields
}

this is the core data structure which is passed along with each web request

func Ctx

func Ctx(r *http.Request) *WebCtx

func (*WebCtx) ClientApp

func (wc *WebCtx) ClientApp() *model.OauthClient

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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