fasthttpupdate

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fasthttpupdate is the fasthttp half of the partial-update surface. It declares the same names as htmlupdate over *fasthttp.RequestCtx, so generated code imports it under the htmlupdate alias and its call selectors read the same on either transport:

import htmlupdate "github.com/shibukawa/tinybind-go/fasthttpupdate"

What is here, and what is not

The entries that read a request and write nothing through it are all here: the action pair, the redraw, the sequence, the CSRF reads, the negotiation, and every header computation. Each returns a Response the caller sends, which is what made them portable — they were never coupled to the transport by behaviour, only by a parameter type.

The entries that write as they go are not here, and will not be until the flusher inversion is done: Render, RenderStream, RenderStreamAsync, RenderLiveStream, OpenStream, and OpenLiveStream all hold a response open inside a handler that has not returned, which is precisely what fasthttp moves into SetBodyStreamWriter. A handler calling one is refused at generation with the occurrence named, rather than silently losing its delivery.

Pooled memory

A RequestCtx and every byte slice reachable from it are pooled and reused once the handler returns. Every value read here is produced by converting a pooled byte slice, which copies, so nothing a Response carries can alias the request. The context is the one value passed through rather than copied: it reaches a render that completes before the handler returns, and nothing here retains it.

Index

Constants

View Source
const (
	// ModeDocument is the complete HTML document. It is what a request without
	// a usable render header gets, including one from an incompatible client.
	ModeDocument = updatecore.ModeDocument
	// ModeNavigation returns only the changed boundaries of the same route.
	ModeNavigation = updatecore.ModeNavigation
	// ModeLive returns the deliveries of the same route's live boundaries, on a
	// response held open for as long as the subscriptions live.
	ModeLive = updatecore.ModeLive
	// ModeRedraw returns one registered component's subtree, addressed by the
	// kind and instance headers rather than by the URL path.
	ModeRedraw = updatecore.ModeRedraw
	// ModeSequence returns the static half of one fragment, addressed by a
	// digest of its own content.
	ModeSequence = updatecore.ModeSequence
)
View Source
const (
	// FailureMalformedRequest is a redraw that named no component.
	FailureMalformedRequest = updatecore.FailureMalformedRequest
	// FailureUnknownComponent is a kind this deployment does not publish.
	FailureUnknownComponent = updatecore.FailureUnknownComponent
	// FailureArgumentsTooLarge is a query past the configured bound.
	FailureArgumentsTooLarge = updatecore.FailureArgumentsTooLarge
	// FailureInvalidArguments is a query the generated decoder refused.
	FailureInvalidArguments = updatecore.FailureInvalidArguments
	// FailureRenderFailed is a component that could not render.
	FailureRenderFailed = updatecore.FailureRenderFailed
)
View Source
const (
	// DefaultHeaderPrefix names the request and response headers.
	DefaultHeaderPrefix = updatecore.DefaultHeaderPrefix
	// DefaultPathPrefix is the URL namespace of the endpoints this package owns.
	DefaultPathPrefix = updatecore.DefaultPathPrefix
	// DefaultDataAttributePrefix names the attributes the protocol puts in a
	// document.
	DefaultDataAttributePrefix = updatecore.DefaultDataAttributePrefix
	// DefaultGlobalName is what the browser runtime is installed under.
	DefaultGlobalName = updatecore.DefaultGlobalName
	// DefaultRuntimeFileName names the served runtime file.
	DefaultRuntimeFileName = updatecore.DefaultRuntimeFileName
	// DefaultCSRFFieldName is the hidden field generated forms carry.
	DefaultCSRFFieldName = updatecore.DefaultCSRFFieldName
	// DefaultCSRFHeaderName is where the runtime puts the token.
	DefaultCSRFHeaderName = updatecore.DefaultCSRFHeaderName
	// DefaultMaxManifestBytes bounds the validators a request may carry.
	DefaultMaxManifestBytes = updatecore.DefaultMaxManifestBytes
	// DefaultMaxQueryBytes bounds the arguments a redraw may carry.
	DefaultMaxQueryBytes = updatecore.DefaultMaxQueryBytes
	// DefaultStreamContentType marks a delta delivered as a record stream.
	DefaultStreamContentType = updatecore.DefaultStreamContentType
)

The naming defaults. Each is shared with the generator, which writes what these read back.

Variables

BuildID identifies the running binary, so anything that could change rendering invalidates client state.

View Source
var ErrCSRFMismatch = updatecore.ErrCSRFMismatch

ErrCSRFMismatch reports a token that is not the session's.

View Source
var ErrCSRFMissing = updatecore.ErrCSRFMissing

ErrCSRFMissing reports an unsafe request carrying no token at all.

Functions

func ApplyTo

func ApplyTo(header http.Header, ctx *fasthttp.RequestCtx)

ApplyTo copies a computed header set onto a response, adding rather than replacing so a caller's own values survive.

Content-Type is set rather than added: fasthttp keeps it as a dedicated field with a default already in it, so adding would leave the default beside the computed value and let a proxy pick either.

func DecodeManifest

func DecodeManifest(encoded string) delta.Manifest

DecodeManifest reads the compact validator list a client sends back.

func EncodeManifest

func EncodeManifest(manifest delta.Manifest) string

EncodeManifest renders the validator list a client sends back. It exists so a test, and any non-browser client, can produce exactly what the runtime does.

func QueryBool

func QueryBool(values url.Values, name string, target *bool) error

QueryBool decodes one boolean value.

func QueryFloat

func QueryFloat(values url.Values, name string, target *float64) error

QueryFloat decodes one floating-point value.

func QueryInt

func QueryInt(values url.Values, name string, target *int) error

QueryInt decodes one integer value.

func QueryOptional

func QueryOptional[T any](values url.Values, name string, target **T) error

QueryOptional decodes a value that may be absent, leaving the target nil when it is.

func QueryString

func QueryString[T ~string](values url.Values, name string, target *T) error

QueryString decodes one string-kinded value.

func QueryTime

func QueryTime(values url.Values, name string, target *time.Time) error

QueryTime decodes one date, time, or datetime value.

func QueryURL

func QueryURL(values url.Values, name string, target *url.URL) error

QueryURL decodes one URL value.

func Redirect

func Redirect(ctx *fasthttp.RequestCtx, url string, status int)

Redirect sends the browser somewhere else, for the branch WantsUpdate exists to create. It is the same name and the same meaning as htmlupdate's, over the transport that spells a redirect as a method rather than a function.

The status is passed through rather than defaulted, so a handler choosing 303 after a POST — which is what a form submission wants — gets it on either backend.

func RuntimeSource

func RuntimeSource() []byte

RuntimeSource is the browser runtime this package implements, for a framework merging it into its own asset rather than loading a second one.

func RuntimeVersion

func RuntimeVersion() string

RuntimeVersion is the content identity of the browser runtime. It appears in the runtime path so a new build gets a new URL.

func SetStreamErrorHandler

func SetStreamErrorHandler(fn func(error))

SetStreamErrorHandler installs the destination for stream failures raised after the response committed. It is the same installation htmlupdate and the typed streams use, so one call covers every stream the module opens.

Types

type Asset

type Asset = updatecore.Asset

Asset is one static file this package requires a page to load.

type DeltaStream

type DeltaStream = updatecore.DeltaStream

DeltaStream is an open record stream a producer writes boundary completions to as they settle. It is the same type htmlupdate hands a producer, so a handler body is the same text on both transports.

type Failure

type Failure = updatecore.Failure

Failure is one request an update endpoint could not answer. It satisfies error and unwraps to the cause, so it goes straight to a logger or a span.

type FailureKind

type FailureKind = updatecore.FailureKind

FailureKind names why an update endpoint could not answer.

type ManifestEntry

type ManifestEntry = updatecore.ManifestEntry

ManifestEntry is what a client stores for one instance beside its markup.

type Mode

type Mode = updatecore.Mode

Mode is the rendering a request asked for.

type Negotiated

type Negotiated = updatecore.Negotiated

Negotiated is what a request asked for, after validation.

type Options

type Options struct {
	// Key authenticates validators. Two renders that are to be compared must
	// use the same key; rotating it forces complete documents, which is the
	// intended effect of a rotation.
	//
	// An unkeyed digest of low entropy content lets anyone confirm a guess by
	// comparing digests, so a deployment serving non-public pages must set it.
	Key []byte
	// HeaderPrefix overrides the header namespace. Empty uses
	// DefaultHeaderPrefix. The runtime reads it from its configuration, so
	// overriding it needs no rebuilt runtime.
	HeaderPrefix string
	// DataAttributePrefix overrides the attribute namespace. Empty uses
	// DefaultDataAttributePrefix.
	//
	// It must match the generator's own DataAttributePrefix, because that is
	// what wrote the instance attributes into the markup this runtime reads.
	// It also names the preserve and ignore markers an application author
	// writes by hand, which is why a framework needs to own it: those are the
	// author's surface, not a wire detail.
	DataAttributePrefix string
	// GlobalName overrides the name the browser runtime is installed under.
	// Empty uses DefaultGlobalName.
	//
	// A framework sets it so its users call the framework's own name rather
	// than a dependency's.
	GlobalName string
	// RuntimeFileName overrides the base name of the served runtime asset.
	// Empty uses DefaultRuntimeFileName. The content digest and the .js suffix
	// are appended either way, so the URL stays immutably cacheable.
	RuntimeFileName string
	// CallerOwnsRuntime says the caller ships its own browser runtime, so this
	// package serves and references none: Mount registers no asset route and
	// ScriptTag returns nothing.
	//
	// Usually that runtime is this one, merged into a larger asset from
	// RuntimeSource. Two runtimes on one document would mean two boundary id
	// spaces and two build identities, so a framework that already has one takes
	// this rather than adding a second.
	CallerOwnsRuntime bool
	// ServeRuntime asks this package to serve the reference browser runtime at a
	// content-hashed URL and to write the script tag that loads it.
	//
	// It is off by default, which is the whole of the difference from earlier
	// versions: the browser half belongs to the caller, so serving one is
	// something a deployment asks for rather than something it inherits.
	//
	// Exactly one of this and CallerOwnsRuntime must be set, and Validate says so
	// at startup. A build that set neither would compile and then serve pages
	// that silently stop updating, which is the worst failure shape available
	// here: nothing fails, the page is just quietly dead.
	ServeRuntime bool
	// CSRFFieldName is the hidden field generated forms carry. Empty uses
	// DefaultCSRFFieldName.
	//
	// It must match the generator's own CSRFFieldName, because that is what
	// wrote the field into the markup this reads back: one writes it and the
	// other reads it, and nothing links the two at compile time.
	CSRFFieldName string
	// CSRFHeaderName overrides the header the browser runtime puts the CSRF
	// token in. Empty uses DefaultCSRFHeaderName.
	//
	// It does not follow HeaderPrefix on purpose: the render, manifest, and
	// build headers name this protocol, and this one names a convention every
	// framework's middleware already looks for.
	CSRFHeaderName string
	// PathPrefix overrides the URL namespace of every framework endpoint.
	// Empty uses DefaultPathPrefix. Unlike the header names, the runtime learns
	// this one at load time, so overriding it needs no rebuilt runtime.
	PathPrefix string
	// BuildID overrides the identity of the running binary. Empty uses
	// BuildID(), which is the version control revision the binary was stamped
	// with, or a per-process value when the tree was dirty or unstamped.
	//
	// A page rendered by a different build has client state this binary cannot
	// vouch for, so it is served a complete document instead of a delta.
	BuildID string
	// MaxManifestBytes caps the manifest header a request may carry. Zero uses
	// DefaultMaxManifestBytes. An oversized manifest is ignored rather than
	// rejected, so the response is a larger delta instead of an error.
	MaxManifestBytes int
	// MaxQueryBytes caps the arguments a redraw may carry. Zero uses
	// DefaultMaxQueryBytes. Unlike an oversized manifest an oversized query is
	// rejected, because the arguments are the request rather than a hint.
	MaxQueryBytes int
	// StreamContentType overrides the media type of a streamed delta. Empty
	// uses DefaultStreamContentType.
	//
	// This one names the wire format rather than a limit, so overriding it is a
	// framing choice a client has to agree with, not a tuning knob.
	StreamContentType string
	// OnFailure receives every request an endpoint of this package could not
	// answer. It observes rather than answers.
	//
	// Every entry returns the response it computed, with its Failure field set,
	// so a caller with its own error pages substitutes them by sending something
	// else instead of what it was handed. This hook is for the log line and the
	// span, which a caller wants on every refusal whether or not it changes the
	// answer — and which are otherwise lost, since a status alone cannot say
	// whether a page was stale or a render failed.
	//
	// It takes the request's context rather than the request. A log line and a
	// span both want the trace, the deadline, and whatever the caller's own
	// middleware put there, and none of them want the transport; taking the
	// narrower value is also what lets this field mean the same thing on a
	// backend whose request type is not *http.Request.
	OnFailure func(ctx context.Context, failure Failure)
}

Options configure one set of update endpoints.

func (Options) CSRFToken

func (o Options) CSRFToken(ctx *fasthttp.RequestCtx) string

CSRFToken reads the token a request carries, header first and form body second.

The body channel is the post arguments and the multipart form, never the query, which is what net/http's PostFormValue means and what keeps a token out of access logs and referrers.

func (Options) Headers

func (o Options) Headers(ctx *fasthttp.RequestCtx, wrappers []htmlbind.Wrapper, leaf htmlbind.Fragment) http.Header

Headers is what a response to this request must carry, for the entries that write their body directly and therefore need their headers set first.

func (Options) LiveHeaders

func (o Options) LiveHeaders(ctx *fasthttp.RequestCtx, wrappers []htmlbind.Wrapper, leaf htmlbind.Fragment) http.Header

LiveHeaders is StreamHeaders for an entry that does hold subscriptions open, so a live request keeps the live mode rather than being downgraded.

func (Options) Mount

func (o Options) Mount(router Router)

Mount registers every endpoint this package owns under the configured path prefix, which is the runtime asset and nothing else.

It takes no registry, because a redraw is not an endpoint this package mounts: the caller answers one from its own handler with Options.Redraw, at whatever URL it chooses.

The asset is registered only when this build serves it; see Options.ServeRuntime.

func (Options) Negotiate

func (o Options) Negotiate(ctx *fasthttp.RequestCtx) Negotiated

Negotiate resolves how a request must be answered.

Anything unrecognized resolves to ModeDocument rather than to an error: a stale client, a truncated header, and a proxy that dropped a header must all still produce a working page.

func (Options) Redraw

func (o Options) Redraw(ctx *fasthttp.RequestCtx, reg *Registry, options ...htmlbind.Option) (Response, bool)

Redraw answers a request for one registered component, and reports whether it did.

It is the entry a caller branches on inside its own handler, so the address a client redraws at is the caller's to choose and this package mounts nothing.

The registry and the components in it are the same values on either transport: Reloadable.Render takes a context rather than a request, so one registration built by generation serves both.

func (Options) RedrawHeaders

func (o Options) RedrawHeaders(ctx *fasthttp.RequestCtx) http.Header

RedrawHeaders names the Vary axes a URL that answers redraws depends on, whichever way this request turns out.

A page handler declares them before it branches: a page and the redraws of the components on it share one URL, so a cache that learned only the page would answer a redraw from it.

func (Options) Render

func (o Options) Render(ctx *fasthttp.RequestCtx, wrappers []htmlbind.Wrapper, leaf htmlbind.Fragment, options ...htmlbind.Option) error

Render answers one request with either a complete document or a delta.

It buffers, so it holds nothing open and needs no body stream writer: the delta path encodes one JSON body and the document path writes the collected chain, both inside the handler. Every failure is an ordinary error the caller can still turn into a status.

func (Options) RenderLiveStream

func (o Options) RenderLiveStream(cctx context.Context, ctx *fasthttp.RequestCtx, wrappers []htmlbind.Wrapper, leaf htmlbind.Fragment, options ...htmlbind.Option) error

RenderLiveStream answers a live request by holding the response open for as long as the composition's subscriptions live.

cctx is the caller's cancellation. A *fasthttp.RequestCtx passed here is replaced, because it is pooled and this delivery outlives the handler that owned it; what replaces it carries the one signal a RequestCtx actually has, which is server shutdown.

That is the honest difference from net/http and it is worth stating plainly: there, the request context is cancelled when the client disconnects, and the stream ends promptly. fasthttp has no per-request cancellation at all — its Done channel closes on server shutdown alone — so a client that went away is noticed when a record fails to write instead. A live stream therefore ends at its next delivery rather than at the disconnect, and a subscription that never delivers again holds its resources until the server stops. A caller that needs a bound should pass a context carrying one.

func (Options) RenderStream

func (o Options) RenderStream(ctx *fasthttp.RequestCtx, wrappers []htmlbind.Wrapper, leaf htmlbind.Fragment, options ...htmlbind.Option) error

RenderStream answers a navigation with a record stream instead of one buffered body, so each region applies as soon as it is written.

The whole delta is rendered before the first record, so every failure this entry can have is still an ordinary error: nothing has been written when it returns one.

func (Options) RenderStreamAsync

func (o Options) RenderStreamAsync(cctx context.Context, ctx *fasthttp.RequestCtx, wrappers []htmlbind.Wrapper, leaf htmlbind.Fragment, options ...htmlbind.Option) error

RenderStreamAsync answers a navigation with a record stream that also carries await boundaries as they settle.

Each region reaches the browser with its fallback in place and is replaced when its dependency finishes, so a slow one delays only itself.

cctx is the caller's cancellation and must not be the RequestCtx; see Options.RenderLiveStream for what happens if it is.

func (Options) RuntimeAsset

func (o Options) RuntimeAsset() Asset

RuntimeAsset is the browser runtime as a static asset, for a caller that serves its own files.

func (Options) RuntimeConfig

func (o Options) RuntimeConfig() RuntimeConfig

RuntimeConfig is the configuration matching these options, so the server and the browser cannot disagree about a name. It carries no CSRF token; use RuntimeConfigFor to add one.

func (Options) RuntimeConfigFor

func (o Options) RuntimeConfigFor(csrfToken string) RuntimeConfig

RuntimeConfigFor is RuntimeConfig carrying this session's CSRF token, so the runtime sends it on every request it issues.

func (Options) RuntimeHandler

func (o Options) RuntimeHandler() fasthttp.RequestHandler

RuntimeHandler serves the browser runtime.

A caller owning the runtime serves its own asset and never calls this; see Options.CallerOwnsRuntime and RuntimeSource.

func (Options) RuntimePath

func (o Options) RuntimePath() string

RuntimePath is the URL the browser runtime is served from. The version segment makes the response immutable, which is why the handler may set a long max-age.

func (Options) ScriptTag

func (o Options) ScriptTag() string

ScriptTag is the element loading the runtime, ready to place at the end of a document body. A caller owning the runtime gets an empty string.

func (Options) ScriptTagFor

func (o Options) ScriptTagFor(csrfToken string) string

ScriptTagFor is ScriptTag carrying this session's CSRF token, which is what a handler that renders forms uses.

func (Options) Sequence

func (o Options) Sequence(ctx *fasthttp.RequestCtx) (Response, bool)

Sequence answers a request for one sequence tree, and reports whether it did.

It is the entry a caller branches on inside its own handler, exactly as Redraw is:

func page(ctx *fasthttp.RequestCtx) {
	if answer, ok := options.Sequence(ctx); ok {
		ctx.Response.Header.Set("Cache-Control", "public, max-age=31536000, immutable")
		_, _ = answer.WriteTo(ctx)
		return
	}
	// ordinary page render
}

The cache policy is the caller's, and a sequence is the one answer here that may be public and held forever: it is addressed by a digest of its own content, so a template edit produces a new address rather than a new body at the old one, and nothing needs invalidating.

func (Options) StreamHeaders

func (o Options) StreamHeaders(ctx *fasthttp.RequestCtx, wrappers []htmlbind.Wrapper, leaf htmlbind.Fragment) http.Header

StreamHeaders is Headers for a streamed navigation, whose body is a record stream rather than one of the buffered shapes.

The entry that writes such a stream is not in this package yet; the headers are, because a caller driving SetBodyStreamWriter itself needs exactly these and nothing about computing them depends on holding a response open.

func (Options) Validate

func (o Options) Validate() error

Validate reports a configuration this package cannot serve.

func (Options) VerifyCSRF

func (o Options) VerifyCSRF(ctx *fasthttp.RequestCtx, expected string) error

VerifyCSRF compares what a request carries against the session's token.

expected is the caller's to produce, from wherever its session lives. An empty expected is refused rather than treated as "nothing to check": a session lookup that quietly returned nothing would otherwise disable the whole control for exactly the requests that most need it.

func (Options) WantsUpdate

func (o Options) WantsUpdate(ctx *fasthttp.RequestCtx) bool

WantsUpdate reports whether this request can be answered with the regions an action changed, rather than with a redirect. See htmlupdate for the whole rule; this is the same entry over the other transport.

func (Options) WriteLiveStream

func (o Options) WriteLiveStream(ctx *fasthttp.RequestCtx, head []string, fn func(*DeltaStream) error)

WriteLiveStream is WriteStream for a delivery stream: the same records on the same framing, in the live mode rather than the navigation one, so the terminator can mean "come back" rather than "stop".

func (Options) WriteNavigate

func (o Options) WriteNavigate(url string) (Response, error)

WriteNavigate tells the browser to leave the page, which is how an action that changed where the user belongs stays correct without guessing which regions to rewrite.

func (Options) WriteStream

func (o Options) WriteStream(ctx *fasthttp.RequestCtx, head []string, fn func(*DeltaStream) error)

WriteStream opens a record stream, runs fn against it, and closes it.

fn runs from the body stream writer, after the handler has returned, so it must not read ctx. Everything the stream needs is captured before this call returns. An error from fn is reported in band through the terminator and then sent to the handler installed with SetStreamErrorHandler, because the response committed when the head record went out.

func (Options) WriteUpdate

func (o Options) WriteUpdate(ctx *fasthttp.RequestCtx, updates []Update, options ...htmlbind.Option) (Response, error)

WriteUpdate answers a mutating request with the regions it changed, so one round trip both performs the action and refreshes the page.

func (Options) WriteUpdateStatus

func (o Options) WriteUpdateStatus(ctx *fasthttp.RequestCtx, status int, updates []Update, options ...htmlbind.Option) (Response, error)

WriteUpdateStatus is WriteUpdate with an explicit status, so a failed validation can return 422 and still rewrite the form region with its errors.

type QueryError

type QueryError = updatecore.QueryError

QueryError is a redraw argument the generated decoder refused.

type Registry

type Registry = updatecore.Registry

Registry holds the components a deployment publishes for redraw.

type Reloadable

type Reloadable = updatecore.Reloadable

Reloadable is one component published as a redraw endpoint.

type Response

type Response struct {
	// Status is what this answer means. A caller may serve another, and an
	// update response is applied by a client whatever the status says, which is
	// how a rejected form returns 422 and still rewrites its own region.
	Status int
	// Header is what the response has to carry: the Vary axes it depends on, its
	// content type, the served mode echoed back, and an entity tag where the
	// answer has one. It carries no cache policy, which is the caller's.
	Header http.Header
	// Body is the bytes to write.
	Body []byte
	// Failure is why this answer is a refusal, or nil for an ordinary one.
	//
	// It travels here rather than through a hook that writes: a caller that only
	// wants to observe logs it and sends the response as it stands, and one that
	// wants its own error page reads the kind and writes that instead. Either way
	// nothing is written until the caller writes it, which is the whole of this
	// package's position on responses.
	Failure *Failure
}

Response is a complete answer this package computed and did not send.

It exists for the entries whose headers depend on the body — a redraw digests what it rendered — because such an entry cannot both write the body and leave the headers alone. The buffered entries return one; the streaming entries take their headers from Headers instead, since a stream commits before its first record.

func FailureResponse

func FailureResponse(failure Failure) Response

FailureResponse is the refusal this package computes, exported so a caller raising one of its own — a redraw it declined before this package saw it — answers in the same shape rather than reimplementing five status codes.

The body is RFC 9457 problem details, which is this module's documented error format everywhere else; the update endpoints were the only paths writing plain text. The media type is what tells the two apart on the wire: application/json is an update to apply, including a non-2xx one, and application/problem+json is a request that produced no update at all.

The status still directs. A client's rule — any non-2xx falls back to an ordinary navigation — is unchanged, so a client that cannot read the body still lands correctly; the body adds diagnosis rather than direction.

Nothing is sent until a caller sends it: Response.WriteTo does that, and a caller with its own error page sends that instead.

It carries no Vary, having no Options and no request to compute one from. The refusals this package produces get theirs added; a caller raising one of its own adds them from Options.RedrawHeaders or Options.Headers, and a cacheable status makes that matter.

func (Response) NotModified

func (resp Response) NotModified(ctx *fasthttp.RequestCtx) bool

NotModified reports whether the request already holds this answer, by comparing its If-None-Match against the entity tag this response carries.

Answering it is the caller's: a 304 is a cache policy decision, and this package makes none. A response with no entity tag is never a match.

func (Response) WriteTo

func (resp Response) WriteTo(ctx *fasthttp.RequestCtx) (int64, error)

WriteTo sends the response: its headers, its status, and its body.

It is here so the common case is one call and an omission is a decision. A caller wanting its own policy sets it on ctx before calling, or copies Header itself and writes Body.

type Router

type Router interface {
	Handle(method, path string, handler fasthttp.RequestHandler)
}

Router is what Mount installs on.

It names the one method Mount uses, so a framework with its own router passes it directly instead of losing the call. The forked router satisfies it.

type RuntimeConfig

type RuntimeConfig = updatecore.RuntimeConfig

RuntimeConfig is what the browser runtime reads to learn its own names.

type StreamPlan

type StreamPlan = updatecore.StreamPlan

StreamPlan is what a stream entry decided before it committed.

type Update

type Update = updatecore.Update

Update is one region an action rewrote.

func Replace

func Replace(targetID string, fragment htmlbind.Fragment) Update

Replace rewrites the region addressed by targetID with fragment.

Jump to

Keyboard shortcuts

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