cradix

Version, currently 1.0.02 versions

github.com/globoplox/cradix

A simple radix like url path router in crystal lang

1 stars
1 dependent
License: MIT

Nothing has been indexed for 1.0.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  cradix:
    github: globoplox/cradix
    version: ~> 1.0.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 1.0.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

Cradix

A simple radix like tree specialized in URL path routing with supports for path parameters and wildcards, in crystal lang.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      cradix:
        github: globoplox/cradix
  2. Run shards install

Usage

require "cradix"

radix = Cradix(String).new
radix.add "/users", "List users"
radix.add "/users/:id", "Get a user by id"
radix.add "/users/:id/file/*", "Get a user file by path"
radix.add "/users/self", "Get the current login in user"
puts radix.search("/users/toto").first # => {"Get a user by id", {"id" => "toto"}, nil}
puts radix.search("/users/self").first # => {"Get the current login in user", {}, nil}
puts radix.search("/users/toto/file/holiday/beach.raw").first # => {"Get a user file by path", {"id" => "toto"}, "/holiday/beach.raw"} 

Changelog

[1.1.0] - 2025-02-11

Added

  • Support for wildcard (in addition to existing support of path parameters)