Skip to content
scalive
Menu
ConnectingLiveReconnectingOffline
o

LiveParamsCodec

object LiveParamsCodec

Standard codecs, encoded values, and errors for typed Live route parameters.

Defined by scalive.LiveParamsCodec. View source (scalive/api/src/scalive/LiveParamsCodec.scala:119-242)

Methods5

custom

def custom[PathParams, Params](decodeFn: (PathParams, zio.http.URL) => Either[|[LiveParamsCodec.DecodeError, String], Params], encodeFn: Params => Either[LiveLocation.EncodeError, LiveParamsCodec.Encoded[PathParams]]): LiveParamsCodec[PathParams, Params]

Creates a bidirectional parameter codec from application functions.

A string returned by decodeFn is normalized to DecodeError(message). Both functions are expected to be total: thrown exceptions are not converted into their declared error channels. encodeFn should classify path and query failures with the corresponding EncodeError.

Parameters

decodeFn

decodes path values and the complete URL

encodeFn

encodes typed parameters to route path/query values

Returns

Returns

a bidirectional custom codec

Defined by scalive.LiveParamsCodec.custom. View source (scalive/api/src/scalive/LiveParamsCodec.scala:226-233)

fromQuery

def fromQuery[PathParams, QueryParams](codec: zio.http.codec.package.QueryCodec[QueryParams])(using combiner: zio.http.codec.Combiner[PathParams, QueryParams]): LiveParamsCodec[PathParams, combiner.Out]

Combines route path values with parameters handled by a ZIO HTTP query codec.

The implicit Combiner determines the resulting tuple or simplified value and separates it again during encoding. Query encoding exceptions are caught and returned as Query.

Parameters

codec

the query codec used for request decoding and encoding

combiner

combines path and query values and separates them for encoding

Returns

Returns

a codec for the combiner's output type

Defined by scalive.LiveParamsCodec.fromQuery. View source (scalive/api/src/scalive/LiveParamsCodec.scala:193-210)

fromZioHttp

def fromZioHttp[A](codec: zio.http.codec.package.QueryCodec[A]): LiveParamsCodec[Unit, A]

Adapts a ZIO HTTP query codec to a query-only Live parameter codec.

Parameters

codec

the query codec used for request decoding and encoding

Returns

Returns

a Live parameter codec whose path value is Unit

Defined by scalive.LiveParamsCodec.fromZioHttp. View source (scalive/api/src/scalive/LiveParamsCodec.scala:177-178)

path

def path[A]: LiveParamsCodec[A, A]

Uses the decoded path value itself as the routed parameters.

Encoding preserves the path value and emits no query parameters.

Returns

Returns

an identity codec for path values

Defined by scalive.LiveParamsCodec.path. View source (scalive/api/src/scalive/LiveParamsCodec.scala:153-157)

query

def query[A](using x$1: zio.schema.Schema[A]): LiveParamsCodec[Unit, A]

Derives query-only parameters from a ZIO Schema.

Returns

Returns

a codec with no path values and schema-derived query parameters

Defined by scalive.LiveParamsCodec.query. View source (scalive/api/src/scalive/LiveParamsCodec.scala:167-168)

Values1

none

val none: LiveParamsCodec[Unit, Unit]

A codec for routes with neither path values nor routed parameters.

Defined by scalive.LiveParamsCodec.none. View source (scalive/api/src/scalive/LiveParamsCodec.scala:160-160)