Documentation
¶
Index ¶
- func Created(w http.ResponseWriter, data any)
- func Download(w http.ResponseWriter, r *http.Request, filePath string, fileName string)
- func Error(w http.ResponseWriter, status int, message string)
- func Flash(w http.ResponseWriter, r *http.Request, key string, value any)
- func FlashInput(w http.ResponseWriter, r *http.Request)
- func JSON(w http.ResponseWriter, status int, data any)
- func Ok(w http.ResponseWriter, data any)
- func Redirect(w http.ResponseWriter, r *http.Request, url string, status int)
- func RedirectBack(w http.ResponseWriter, r *http.Request, fallback string, status int)
- func RedirectToRoute(w http.ResponseWriter, r *http.Request, name string, params map[string]string, ...)
- func Stream(w http.ResponseWriter, callback func(w http.ResponseWriter)) error
- func StreamLines(w http.ResponseWriter, callback func(w http.ResponseWriter) error) error
- func StreamSSE(w http.ResponseWriter, events <-chan SSEEvent) error
- func StreamTimer(w http.ResponseWriter, interval time.Duration, callback func(int) string) error
- type SSEEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Created ¶
func Created(w http.ResponseWriter, data any)
Created writes a 201 Created JSON response.
func Error ¶
func Error(w http.ResponseWriter, status int, message string)
Error writes a JSON formatted error response.
func FlashInput ¶
func FlashInput(w http.ResponseWriter, r *http.Request)
FlashInput stores all input data in flash for next request.
func JSON ¶
func JSON(w http.ResponseWriter, status int, data any)
JSON writes a JSON response with the given status code.
func RedirectBack ¶
RedirectBack redirects to the previous URL (from Referer header) or fallback.
func RedirectToRoute ¶
func RedirectToRoute(w http.ResponseWriter, r *http.Request, name string, params map[string]string, status int)
RedirectToRoute redirects to a named route. Usage: response.RedirectToRoute(w, r, "user.show", map[string]string{"id": "1"}, http.StatusFound)
func Stream ¶
func Stream(w http.ResponseWriter, callback func(w http.ResponseWriter)) error
Stream allows streaming a response back to the client using a callback.
func StreamLines ¶
func StreamLines(w http.ResponseWriter, callback func(w http.ResponseWriter) error) error
StreamLines streams content line by line with a callback.
func StreamSSE ¶
func StreamSSE(w http.ResponseWriter, events <-chan SSEEvent) error
StreamSSE streams Server-Sent Events to the client.
func StreamTimer ¶
StreamTimer streams events at regular intervals.