ConfigCodecWithModules<R extends KaiselRoute> class

A KaiselConfigCodec that composes a base codec with one or more module mounts.

URLs whose path starts with a mount's prefix are routed to the module's codec; everything else goes to baseCodec. The host's main codec doesn't need to know the module's internal URL structure; modules ship that themselves.

final codec = ConfigCodecWithModules<AppRoute>(
  baseCodec: const _MainAppCodec(),
  modules: const [
    ModuleMount(
      mountRoute: CheckoutMount(),
      prefix: '/checkout',
      codec: CheckoutModuleCodec(),
    ),
  ],
);

On encode, the composer inspects the top of the main stack: if it matches a mount's mountRoute, it uses that mount's codec to produce the segments after the prefix. Otherwise it delegates to baseCodec.

On decode, the composer walks modules in order, looking for the first whose prefix matches the URL's leading segments. If a match is found, the module codec gets the relative segments. If the module codec returns null (URL inside the prefix but unrecognised), the composer returns null directly. It does NOT fall through to baseCodec, because the URL clearly belongs to this module's namespace.

Implemented types

Constructors

ConfigCodecWithModules({required KaiselConfigCodec<R> baseCodec, required List<ModuleMount<R>> modules})
Create a composer.
const

Properties

baseCodec KaiselConfigCodec<R>
Codec for routes outside any module. Receives configurations whose top route is NOT a registered mount route.
final
hashCode int
The hash code for this object.
no setterinherited
modules List<ModuleMount<R>>
Module mount declarations. Order matters: longer prefixes should come first.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

decode(Uri uri) KaiselConfig<R>?
Decode a URL into a configuration, or return null if unrecognised (the parser will then use the fallback stack).
override
encode(KaiselConfig<R> config) Uri
Encode a configuration into a URL.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited