context

package
v0.0.0-...-27a24ba Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SessionKeyUserID = "nekobox:auth:user-id"

Variables

This section is empty.

Functions

func Contexter

func Contexter(gormDB *gorm.DB) flamego.Handler

Contexter initializes a classic context for a request.

func Toggle

func Toggle(options *ToggleOptions) flamego.Handler

Types

type Context

type Context struct {
	flamego.Context

	IsSignedIn bool
	User       *db.User
}

Context represents context of a request.

func (*Context) Error

func (c *Context) Error(statusCode int, message string, v ...interface{}) error

Error sends an error response with a specific status code and message.

func (*Context) IP

func (c *Context) IP() string

IP retrieves the client's IP address from the request.

func (*Context) ServerError

func (c *Context) ServerError() error

ServerError sends a 500 Internal Server Error response.

func (*Context) Status

func (c *Context) Status(statusCode int)

Status sets the HTTP status code for the response.

func (*Context) Success

func (c *Context) Success(data ...interface{}) error

Success sends a successful response with optional data.

type ToggleOptions

type ToggleOptions struct {
	UserSignInRequired  bool
	UserSignOutRequired bool
}

Jump to

Keyboard shortcuts

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