Back to Pocketbase

Interface Handler

static/jsvm/interfaces/http.Handler.html

latest1.7 KB
Original Source

Interface Handler

A Handler responds to an HTTP request.

[Handler.ServeHTTP] should write reply headers and data to the [ResponseWriter] and then return. Returning signals that the request is finished; it is not valid to use the [ResponseWriter] or read from the [Request.Body] after or concurrently with the completion of the ServeHTTP call.

Depending on the HTTP client software, HTTP protocol version, and any intermediaries between the client and the Go server, it may not be possible to read from the [Request.Body] after writing to the [ResponseWriter]. Cautious handlers should read the [Request.Body] first, and then reply.

Except for reading the body, handlers should not modify the provided Request.

If ServeHTTP panics, the server (the caller of ServeHTTP) assumes that the effect of the panic was isolated to the active request. It recovers the panic, logs a stack trace to the server error log, and either closes the network connection or sends an HTTP/2 RST_STREAM, depending on the HTTP protocol. To abort a handler so the client sees an interrupted response but the server doesn't log an error, panic with the value [ErrAbortHandler].

Hierarchy

  • Handler

Indexable

Index

Methods

serveHTTP

Methods

serveHTTP

  • serveHTTP(_arg0, _arg1): void

Parameters

_arg0: ResponseWriter
_arg1: Request

Returns void

Settings

Member Visibility

  • Inherited

Theme

OSLightDark

On This Page

Generated using TypeDoc