{"id":18620844,"url":"https://github.com/exts/crim","last_synced_at":"2025-11-03T12:30:27.222Z","repository":{"id":114940289,"uuid":"78601596","full_name":"exts/Crim","owner":"exts","description":"Crystal Language Micro Framework inspired by PHP's Slim Framework 3 and other micro frameworks","archived":false,"fork":false,"pushed_at":"2017-01-14T14:35:38.000Z","size":24,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T04:26:25.037Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-11T04:06:56.000Z","updated_at":"2017-09-15T00:47:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"3894d591-2d51-4bbd-b2a8-07d27a54e162","html_url":"https://github.com/exts/Crim","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exts%2FCrim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exts%2FCrim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exts%2FCrim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exts%2FCrim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exts","download_url":"https://codeload.github.com/exts/Crim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239414231,"owners_count":19634397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T04:08:11.501Z","updated_at":"2025-11-03T12:30:27.192Z","avatar_url":"https://github.com/exts.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crim\n\nCrim is a crystal language micro framework inspired by Slim Framework 3 and other micro frameworks from PHP.\n\nI made Crim to learn Crystal and it introduces me to a lot of different features of the language from macros to regular expressions. So far I believe I've used a lot of the crystal language base features in this project and it's been a blast. If you have any feedback or want to contribute please feel free to add a PR, but please remember currently not everything will be accepted as I'd like to dictate and keep this micro framework as minimal as possible.\n\n## Development\n\nCrim is in early stages so please bare with me while I get the base of the project complete before contributing or using this framework.\n\n## Installation\n\nAdd the following to your dependencies\n\n    dependencies:\n      Crim:\n        github: exts/Crim\n        version: \u003c=1.0.0\n\n## Example Application\n\n    require \"Crim\"\n\n    include Crim::Http::Handlers\n    include Crim::Http::Router\n\n    # Example Action Controller\n    class ExampleController \u003c Action\n      def action(request, response)\n        response.write \"hello!, World it works!\".to_slice\n        response\n      end\n    end\n\n    routes = RouteContainer.new\n    routes.get \"/\", {controller: ExampleController.new, action: nil}\n\n    app = Crim::Server.new\n    app.add_middleware LogHandler.new \"example.log\"\n    app.add_middleware RouteHandler.new routes\n    app.run\n\n## Routes \u0026 Group Routes\n\nAll routes require a route (`String`) and a `NamedTuple(controller: Action, action: String)` when being called. You also have optional parameters `default` and `regex`. Default allows you to force default values for named variables that don't match anything. You'd usually want to use it for optional parameters. The regex parameter allows you to force a named route variable to match your regular expression. So for instance you'd want only numbers for \"page\" you could do `{\"page\" =\u003e %q(\\d+)}`. Currently the default \u0026 regex parameters are stored as a `Hash(String, String)`. I'm contemplating changing it to `Hash(String, String | Int32 | Float32)`, for now it seems fine for what we need.\n\n**Example of Group Routes**\n\n    routes = RouteContainer.new\n    routes.group \"/admin\", do |route|\n      route.group \"/users\", do |route|\n        route.any \"/update/:id\", {controller: ExampleController.new, action: \"update\"}\n      end\n    end\n\n_(Note: Group routes can be as deep as you want, but I wouldn't recommend it)_\n\n**Example use of default \u0026 regex**\n\n    routes = RouteContainer.new\n    routes.any \"/post/:id[/:page]\", {controller: ExampleController.new, action: nil}, default: {\"page\", \"1\"}\n\nor\n\n    routes = RouteContainer.new\n    routes.any \"/post/:id[/:page]\", {controller: ExampleController.new, action: nil}, {\"id\", %q(\\d+)}, {\"page\", \"1\"}   \n\n**Optional Routes**\n\nCrim offers the ability to have optional routes because we use a cheap solution on converting square brackets into optional non capturing groups `[]` =\u003e `(?:)?` which allows us to pretty much have infinite grouped optional parameters like so:\n\n`/route[/:example[/:sub_route[/:another_sub_route]]]`\n\n## Contributors\n\n- [[exts]](https://github.com/exts) Lamonte - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexts%2Fcrim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexts%2Fcrim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexts%2Fcrim/lists"}