Stream: API design

Topic: URL-based routing in a webserver


view this post on Zulip Richard Feldman (Nov 13 2023 at 01:22):

I don't think I'd ever actually tried this before (although I remember discussing it on Zulip in the past), but it's really cool that this style already works today!

    url = "/foo/bar/baz/hello"

    when Str.split url "/" is
        ["", "foo", middle, "baz", last] -> ...
        _ -> ...

view this post on Zulip Richard Feldman (Nov 13 2023 at 02:06):

if that style gets used a lot, that pattern match might be something we end up wanting to optimize

view this post on Zulip Isaac Van Doren (Nov 13 2023 at 03:32):

Mmm that is really nice. I like how explicit it is while still being succinct.

view this post on Zulip Rene Mailaender (Jan 19 2024 at 14:14):

Yeah, this works really well. I use this approach on a server project right now and it’s great.


Last updated: Jul 06 2025 at 12:14 UTC