send

package
v1.46.7 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0, Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(client *clients.Client, message string)

BadRequest sends a message with status 400 Bad Request.

func BadRequestf added in v1.46.0

func BadRequestf(client *clients.Client, message string, vars ...any)

BadRequestf sends a message with status 400 Bad Request.

func Content

func Content(client *clients.Client, data []byte)

Content sends binary safe content.

Compatible with web sockets and server sent events.

func ContentType

func ContentType(client *clients.Client, ctype string)

ContentType sets the Content-Type header field.

func Cookie(client *clients.Client, key string, value string)

Cookie sends a cookies to the client.

func Error

func Error(client *clients.Client, err error)

Error sends a message with status 500 Internal Server Error.

func EventContent

func EventContent(client *clients.Client, data []byte)

EventContent sends content using the `server sent events` format.

Usually this should be used internally in order to send content to a Server sent event.

That being said, other than the format, there is nothing else different between this function and ResponseSendContent.

See https://html.spec.whatwg.org/multipage/server-sent-events.html for more details on the format.

func Flush

func Flush(client *clients.Client)

Flush send an empty message.

Compatible with web sockets and server sent events.

func Forbidden

func Forbidden(client *clients.Client, message string)

Forbidden sends a message with status 403 Forbidden.

func Forbiddenf added in v1.46.0

func Forbiddenf(client *clients.Client, message string, vars ...any)

Forbiddenf sends a message with status 403 Forbidden.

func Header(client *clients.Client, key string, value string)

Header sends a header field.

If the status has not been sent already, a default "200 OK" status will be sent immediately.

This means the status will become locked and further attempts to send the status will fail with an error.

All errors are sent to the server notifier.

func Headers

func Headers(client *clients.Client, fields map[string]string)

Headers sends header fields.

func Json

func Json(client *clients.Client, value any)

Json sends json content.

Compatible with web sockets and server sent events.

func Message

func Message(client *clients.Client, message string)

Message sends utf-8 safe content.

Compatible with web sockets and server sent events.

func Messagef

func Messagef(client *clients.Client, format string, vars ...any)

Messagef sends utf-8 safe content using a format.

Compatible with web sockets and server sent events.

func Navigate(client *clients.Client, location string)

Navigate redirects the request to a location with status 302.

func Navigatef(client *clients.Client, format string, vars ...any)

Navigatef redirects the request to a location with status 302.

func NotFound

func NotFound(client *clients.Client, message string)

NotFound sends a message with status 404 Not Found.

func NotFoundf added in v1.46.0

func NotFoundf(client *clients.Client, message string, vars ...any)

NotFoundf sends a message with status 404 Not Found.

func Redirect

func Redirect(client *clients.Client, location string, status int)

Redirect redirects the request to a location with a status.

func Redirectf added in v1.46.0

func Redirectf(client *clients.Client, status int, location string, vars ...any)

Redirectf redirects the request to a location with a status.

func RequestedFile added in v1.44.2

func RequestedFile(client *clients.Client) bool

RequestedFile sends the file requested by the client.

Returns false if connection is web sockets, server sent events or the file was not found.

func SseUpgrade

func SseUpgrade(client *clients.Client) func(event string)

SseUpgrade upgrades to server sent events and returns a function that sets the name of the current event.

The default event name is "message".

func Status

func Status(client *clients.Client, status int)

Status sets the status code.

This will lock the status, which makes it so that the next time you invoke this function it will fail with an error.

All errors are sent to the server notifier.

func TooManyRequests

func TooManyRequests(client *clients.Client, message string)

TooManyRequests sends a message with status 429 Too Many Requests.

func TooManyRequestsf added in v1.46.0

func TooManyRequestsf(client *clients.Client, message string, vars ...any)

TooManyRequestsf sends a message with status 403 Forbidden.

func Unauthorized

func Unauthorized(client *clients.Client, message string)

Unauthorized sends a message with status 401 Unauthorized.

func Unauthorizedf added in v1.46.0

func Unauthorizedf(client *clients.Client, message string, vars ...any)

Unauthorizedf sends a message with status 401 Unauthorized.

func View

func View(client *clients.Client, view views.View)

View sends a view.

func WsUpgrade

func WsUpgrade(client *clients.Client)

WsUpgrade upgrades to web sockets.

func WsUpgradeWithUpgrader

func WsUpgradeWithUpgrader(client *clients.Client, upgrader websocket.Upgrader)

WsUpgradeWithUpgrader upgrades to web sockets.

Types

This section is empty.

Jump to

Keyboard shortcuts

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