handler

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticator

func Authenticator(next http.Handler) http.Handler

func CSRFMiddleware added in v0.1.9

func CSRFMiddleware(next http.Handler) http.Handler

func ChangeSessionRole

func ChangeSessionRole(w http.ResponseWriter, r *http.Request)

func ClearCSRFCookie added in v0.1.9

func ClearCSRFCookie(w http.ResponseWriter, secure bool)

func ClearJWTCookie added in v0.1.9

func ClearJWTCookie(w http.ResponseWriter, r *http.Request, domain string)

func CreateTestAdminUser added in v0.1.5

func CreateTestAdminUser(id, email, password string) *ent.AdminUser

CreateTestAdminUser creates a test AdminUser entity

func CreateTestAdminUserWithDefaultRole added in v0.1.5

func CreateTestAdminUserWithDefaultRole(user *ent.AdminUser, role *ent.Role) *ent.AdminUser

CreateTestAdminUserWithDefaultRole creates a test AdminUser with DefaultRole in Edges

func CreateTestRole added in v0.1.5

func CreateTestRole(id, name string) *ent.Role

CreateTestRole creates a test Role entity

func HandlerWithHeaders

func HandlerWithHeaders(
	title, endpoint string,
	fetcherHeaders, uiHeaders map[string]string,
) http.HandlerFunc

HandlerWithHeaders sets up the playground. fetcherHeaders are used by the playground's fetcher instance and will not be visible in the UI. uiHeaders are default headers that will show up in the UI headers editor.

func Login

func Login(w http.ResponseWriter, r *http.Request)

TODO: 1. sanitize error messages; 2. move to api; 3. add logs;

func NewCSRFToken added in v0.1.9

func NewCSRFToken() (string, error)

func Playground

func Playground(title, endpoint string) http.HandlerFunc

Handler responsible for setting up the playground

func SecurityHeaders added in v0.1.9

func SecurityHeaders(cfg *config.Config) func(http.Handler) http.Handler

SecurityHeaders sets baseline HTTP security headers on every response. HSTS is only set in production and only when the request is HTTPS (direct TLS or X-Forwarded-Proto=https).

func ServeAdmin added in v0.1.6

func ServeAdmin() http.Handler

func ServeFS added in v0.1.6

func ServeFS(fsys fs.FS) http.Handler

ServeFS serves files from a provided fs.FS under the given urlPrefix. Behavior: serves files, serves directory/index.html if present, falls back to root index.html for SPA routes.

func SetCSRFCookie added in v0.1.9

func SetCSRFCookie(w http.ResponseWriter, token string, secure bool)

func SetJWTCookie added in v0.1.9

func SetJWTCookie(w http.ResponseWriter, r *http.Request, token string, domain string)

func Signup

func Signup(w http.ResponseWriter, r *http.Request)

TODO: 1. sanitize error messages; 2. move to api; 3. add logs;

Types

type ChangeSessionRoleRequest

type ChangeSessionRoleRequest struct {
	Role string
}

type IPRateLimiter added in v0.1.9

type IPRateLimiter struct {
	// contains filtered or unexported fields
}

func NewIPRateLimiter added in v0.1.9

func NewIPRateLimiter(rpm int) *IPRateLimiter

func (*IPRateLimiter) Middleware added in v0.1.9

func (l *IPRateLimiter) Middleware(next http.Handler) http.Handler

type LoginFormData

type LoginFormData struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type SignupFormData

type SignupFormData struct {
	Email     string `json:"email"`
	Password  string `json:"password"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
}

type User

type User interface {
	DefaultRole(ctx context.Context) (*ent.Role, error)
}

Jump to

Keyboard shortcuts

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