controller

package
v0.0.0-...-afd8780 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct{}

Base provides common controller functionality

func (*Base) BadRequest

func (c *Base) BadRequest(w http.ResponseWriter, message string)

BadRequest renders 400

func (*Base) BindJSON

func (c *Base) BindJSON(r *http.Request, v interface{}) error

BindJSON binds JSON request body to a struct

func (*Base) Forbidden

func (c *Base) Forbidden(w http.ResponseWriter)

Forbidden renders 403

func (*Base) InternalServerError

func (c *Base) InternalServerError(w http.ResponseWriter, message string)

InternalServerError renders 500

func (*Base) JSON

func (c *Base) JSON(w http.ResponseWriter, data interface{})

JSON renders JSON response

func (*Base) JSONStatus

func (c *Base) JSONStatus(w http.ResponseWriter, status int, data interface{})

JSONStatus renders JSON with custom status code

func (*Base) NotFound

func (c *Base) NotFound(w http.ResponseWriter)

NotFound renders 404

func (*Base) Param

func (c *Base) Param(r *http.Request, name string) string

Param retrieves a single route parameter

func (*Base) Params

func (c *Base) Params(r *http.Request) map[string]string

Params retrieves route parameters

func (*Base) Redirect

func (c *Base) Redirect(w http.ResponseWriter, r *http.Request, url string)

Redirect redirects to a URL

func (*Base) Render

func (c *Base) Render(w http.ResponseWriter, r *http.Request, templateName string, data interface{})

Render renders an HTML template

func (*Base) Text

func (c *Base) Text(w http.ResponseWriter, text string)

Text renders plain text

func (*Base) Unauthorized

func (c *Base) Unauthorized(w http.ResponseWriter)

Unauthorized renders 401

func (*Base) UnprocessableEntity

func (c *Base) UnprocessableEntity(w http.ResponseWriter, data interface{})

UnprocessableEntity renders 422

Jump to

Keyboard shortcuts

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