{"modulePath":"github.com/xmapst/taskflow","version":"v0.0.0-20261127030116-2fa33bcfeb3e","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package httpx\n\n## Functions\n\n```go\nfunc CloseWs(ws *websocket.Conn, message string)\n```\n\n```go\nfunc DecodeStreamParams(params jsontext.Value, value any) error\n```\nDecodeStreamParams decodes parameters using the exact JSON field names. Empty or null parameters leave value unchanged.\n\n```go\nfunc PingWs(ctx context.Context, ws *websocket.Conn) error\n```\n\n```go\nfunc QueryDefault(r *http.Request, key, fallback string) string\n```\n\n```go\nfunc SaveFiles(r *http.Request, path string, maxMemory int64, perm os.FileMode) error\n```\nSaveFiles creates the destination directory and saves the multipart files in it.\n\n```go\nfunc SaveFilesRoot(r *http.Request, root *os.Root, path string, maxMemory int64, perm os.FileMode) error\n```\nSaveFilesRoot confines all filesystem operations, including symlink resolution, to root. The caller owns root.\n\n```go\nfunc SaveToTarFile(r *http.Request, path string, maxMemory int64) (err error)\n```\nSaveToTarFile writes the multipart files to an uncompressed tar archive.\n\n```go\nfunc Send(w http.ResponseWriter, r *http.Request, v any)\n```\nSend encodes a response as JSON or YAML according to the Accept header.\n\n```go\nfunc Upgrade(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)\n```\n\n```go\nfunc UploadName(file *multipart.FileHeader) (string, error)\n```\nUploadName preserves directory uploads without accepting paths outside the root.\n\n```go\nfunc WaitPoll(ctx context.Context, delay time.Duration) bool\n```\nWaitPoll sleeps for the poll interval and reports whether the caller should continue.\n\n```go\nfunc WriteWsJSON(ctx context.Context, ws *websocket.Conn, value any) error\n```\n\n## Types\n\n```go\ntype Snapshot[T any] struct {\n\tCode api.Code\n\tData T\n\tErr  error\n}\n```\nSnapshot is one reading of a query: the value plus the code and error that describe it.\n\n```go\ntype SnapshotFunc[T any] func(ctx context.Context) (api.Code, T, error)\n```\nSnapshotFunc reads the current state. It must return fresh data, since the previous reading is retained to detect changes.\n\n```go\ntype SnapshotSession[T any] struct {\n\tQuery    SnapshotFunc[T]\n\tInterval time.Duration\n\tFrame    func(Snapshot[T]) (api.StreamFrame, bool)\n\tDone     func(Snapshot[T]) bool\n\t// contains filtered or unexported fields\n}\n```\nSnapshotSession polls a query and emits a frame only when the reading changes. Frame decides whether a change is worth sending, Done decides whether the subscription is complete after that reading.\n\n```go\nfunc (s *SnapshotSession[T]) Close()\n```\nClose is a no-op: a polling session holds nothing that outlives the subscription context the transport cancels for it.\n\n```go\nfunc (s *SnapshotSession[T]) Next(ctx context.Context) (api.StreamFrame, error)\n```\n\n```go\ntype StreamCall func(ctx context.Context, params jsontext.Value) (any, error)\n```\nStreamCall answers a request that is not a subscription.\n\n```go\ntype StreamRegistry struct {\n\t// contains filtered or unexported fields\n}\n```\nStreamRegistry is the routing table of the multiplexed WebSocket: topics are long-lived subscriptions, methods are one-shot calls.\n\n```go\nfunc NewStreamRegistry() *StreamRegistry\n```\n\n```go\nfunc (g *StreamRegistry) Method(name string, call StreamCall)\n```\nMethod registers a one-shot method.\n\n```go\nfunc (g *StreamRegistry) Serve(w http.ResponseWriter, r *http.Request)\n```\nServe upgrades the request and multiplexes every subscription and call of the connection over that single socket. All writes are owned by one goroutine, so frames from different sessions cannot interleave.\n\n```go\nfunc (g *StreamRegistry) Topic(name string, topic StreamTopic)\n```\nTopic registers a subscription topic.\n\n```go\ntype StreamSession interface {\n\tNext(ctx context.Context) (api.StreamFrame, error)\n\tClose()\n}\n```\nStreamSession produces the frames of one subscription. Next blocks until a frame is ready and returns io.EOF once the subscription is complete. Close may run concurrently with Next and must not block.\n\n```go\ntype StreamTopic func(params jsontext.Value) (StreamSession, error)\n```\nStreamTopic opens a session for the parameters a client subscribed with.\n\n","path":"github.com/xmapst/taskflow/api/httpx","name":"httpx","synopsis":"","isRedistributable":true}
