A REST-like API micro-framework for Elixir, inspired by Grape, designed for building modular and structured web services.
Maru is a REST-like API micro-framework for Elixir, inspired by Ruby's Grape framework. It provides a Domain-Specific Language (DSL) for building modular, versioned, and well-structured RESTful APIs with built-in features like parameter validation and error handling. The framework integrates seamlessly with the Elixir ecosystem, leveraging Plug and Cowboy for HTTP handling, making it ideal for developing scalable microservices and web applications.
Elixir developers building RESTful APIs, particularly those focused on creating scalable microservices or web applications that require modular organization, versioning, and robust parameter validation. It suits teams seeking a convention-over-configuration approach similar to Ruby's Grape framework.
Developers choose Maru for its clean, declarative DSL that reduces boilerplate while offering powerful built-in features like parameter validation with types and constraints, modular routing for reusable endpoints, and centralized error handling. Its seamless integration with Elixir's Plug and Cowboy ensures reliability and leverages the language's concurrency and fault-tolerance strengths.
Elixir RESTful Framework
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Maru's DSL allows defining parameters with types, constraints, and custom validation, as shown in the README with examples like 'requires :age, type: Integer, values: 18..65' and 'exactly_one_of [:avatar, :avatar_url]' for complex rules.
APIs can be organized into reusable namespaces and mountable modules, enabling clean separation of concerns, demonstrated by 'namespace :user do' and 'mount Router.User' in the example code.
Built-in rescue_from macros allow handling exceptions consistently across the API, with examples for specific errors like 'Unauthorized' and fallbacks for all errors, reducing boilerplate.
Maru leverages Elixir's Plug middleware ecosystem for request processing, as seen with 'plug Plug.Logger' and configurable parsers, making it easy to extend functionality.
Setup requires multiple steps: adding dependencies, configuring the server in mix.exs and Application, and integrating with OTP, which can be complex compared to simpler frameworks.
With version '~> 0.14', Maru is still in development, and users may face breaking changes between releases, as noted by the lack of a stable 1.0 release.
As a smaller framework inspired by Ruby's Grape, Maru has fewer community extensions and third-party integrations compared to Phoenix, potentially requiring more custom development for advanced features.