Skip to content

[Feature] Pattern Matching extensions #642

@baweaver

Description

@baweaver

I'd like to propose adding pattern matching to some of the core classes of http, primarily deconstruct_keys, to allow for matching against things like Responses and Requests.

Consider:

response in {
  status: 200..299,
  body: /Header I want/
}

case response
in { status: 200..299, body: } then Success(body)
in { status: 300.., body: } then Failure(body)
else Failure('unknown')
end

This is just a theoretical example and may not be 100% accurate to the API, but I wanted to run things by the core team before implementing this as it ends up being a decent amount of additional code.

It should be noted that adding the interfaces (deconstruct and deconstruct_keys) will be backward compatible, but testing it with pattern matching will not be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions