{"id":31710087,"url":"https://github.com/emqx/minirest","last_synced_at":"2025-10-09T00:10:48.785Z","repository":{"id":27865357,"uuid":"108507546","full_name":"emqx/minirest","owner":"emqx","description":"A Mini RESTful API Framework","archived":false,"fork":false,"pushed_at":"2025-09-03T10:55:48.000Z","size":302,"stargazers_count":38,"open_issues_count":1,"forks_count":21,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-09-29T22:58:34.723Z","etag":null,"topics":["emqx","restful-api-framework"],"latest_commit_sha":null,"homepage":"https://www.emqx.com","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emqx.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,"zenodo":null}},"created_at":"2017-10-27T06:23:48.000Z","updated_at":"2025-07-22T13:08:05.000Z","dependencies_parsed_at":"2023-09-23T18:34:32.727Z","dependency_job_id":"474d0a8c-ba71-4447-b432-df0cb320e380","html_url":"https://github.com/emqx/minirest","commit_stats":null,"previous_names":[],"tags_count":80,"template":false,"template_full_name":null,"purl":"pkg:github/emqx/minirest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Fminirest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Fminirest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Fminirest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Fminirest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emqx","download_url":"https://codeload.github.com/emqx/minirest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Fminirest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000745,"owners_count":26082879,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["emqx","restful-api-framework"],"created_at":"2025-10-09T00:10:00.901Z","updated_at":"2025-10-09T00:10:48.779Z","avatar_url":"https://github.com/emqx.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# minirest\n\nA mini RESTful API framework built on cowboy and swagger\n\n# UseAge\n## Create erlang application\n\n```shell\nrebar3 new app my_server\n```\n\n## Add dep\nopen `rebar.config` and add minirest in deps\n\n```erlang\n{deps, [{minirest, {git, \"https://github.com/emqx/minirest\", {tag, \"1.1.2\"}}}]}.\n```\n\nAfter add dep, rebar.config file should be like\n```erlang\n{erl_opts, [debug_info]}.\n\n{deps, [{minirest, {git, \"https://github.com/emqx/minirest\", {tag, \"1.1.2\"}}}]}.\n\n{shell, [\n    {apps, [my_server]}\n]}.\n```\n\n## Write an API provider module, example.erl\n\n```erlang\n-module(example).\n\n-behavior(minirest_api).\n\n%% API\n-export([api_spec/0]).\n\n-export([hello/2]).\n\napi_spec() -\u003e\n  {\n    [hello_api()],\n    []\n  }.\n\nhello_api() -\u003e\n    MetaData = #{\n        get =\u003e #{\n            description =\u003e \"hello world\",\n            responses =\u003e #{\n            \u003c\u003c\"200\"\u003e\u003e =\u003e #{\n                content =\u003e #{\n                    'application/json' =\u003e #{\n                        schema =\u003e #{\n                            type =\u003e object,\n                            properties =\u003e #{\n                                msg =\u003e #{\n                                    type =\u003e string}}}},\n                  'text/plain' =\u003e #{\n                        schema =\u003e #{\n                            type =\u003e string}}}}}}},\n  {\"/hello\", MetaData, hello}.\n\nhello(get, #{bindings := Bindins,\n             body := Body,\n             query_string := QueryString,\n             headers := Headers}) -\u003e\n    Content = maps:get(\u003c\u003c\"accept\"\u003e\u003e, Headers),\n    Body =\n        case Content of\n            \u003c\u003c\"text/plain\"\u003e\u003e -\u003e\n                \u003c\u003c\"hello, minirest\"\u003e\u003e;\n             \u003c\u003c\"application/json\"\u003e\u003e -\u003e\n                #{msg =\u003e \u003c\u003c\"hello minirest\"\u003e\u003e}\n        end,\n    {200, #{\u003c\u003c\"content-type\"\u003e\u003e =\u003e Content},  Body}.\n\n\n% Supports callback functions for 2/3 parameters\n% The first parameter is Method\n% The second argument is the parsed parameters, including (bindings, query_string, headers, body)\n% The third argument is the request of cowboy\n-export([hello/3]).\nhello(Method, #{bindings := Bindins,\n                body := Body,\n                query_string := QueryString,\n                headers := Headers}, Request) -\u003e\n    Content = maps:get(\u003c\u003c\"accept\"\u003e\u003e, Headers),\n    Body =\n        case Content of\n            \u003c\u003c\"text/plain\"\u003e\u003e -\u003e\n                \u003c\u003c\"hello, minirest\"\u003e\u003e;\n             \u003c\u003c\"application/json\"\u003e\u003e -\u003e\n                #{msg =\u003e \u003c\u003c\"hello minirest\"\u003e\u003e}\n        end,\n    {200, #{\u003c\u003c\"content-type\"\u003e\u003e =\u003e Content},  Body}.\n\n```\n\n## Start your HTTP server\n\n```erlang\n    ServerName = example_server,\n    App = my_server, %% or your app name\n    {ok, _} = application:ensure_all_started(minirest),\n    Options = #{\n        port =\u003e 8088,\n        apps =\u003e [App]\n    },\n    minirest:start(ServerName, Options).\n```\n\n## Now, Visit `http://localhost:8088/api-docs` and see what happened\n\n## Example\n\nSee detail by example/my_server\n\n## TODO\n\n- Request filter\n\n    query \u0026 headers\n\n- Parameters check\n\n- Test suite\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femqx%2Fminirest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femqx%2Fminirest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femqx%2Fminirest/lists"}