import {failure, success} from "@http4t/result"; import {PathMatcher} from "../PathMatcher"; import {Parser, ParserPath, ParserResult} from "./index"; class BooleanParser implements Parser { parse(pathSegment: string): ParserResult { switch (pathSegment.toLowerCase()) { case "true": return success(true) case "false": return success(false) default: return failure("Expected 'true' or 'false'"); } } unparse(value: boolean): string { return value.toString(); } } export class BooleanPath extends ParserPath { constructor(base: PathMatcher) { super(base, new BooleanParser()) } }