{"id":24548169,"url":"https://github.com/flanker/grape-hal","last_synced_at":"2025-04-15T18:41:36.298Z","repository":{"id":13160511,"uuid":"15843364","full_name":"flanker/grape-hal","owner":"flanker","description":"HAL support for Grape Api","archived":false,"fork":false,"pushed_at":"2014-01-12T14:37:32.000Z","size":140,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T23:43:57.823Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flanker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-12T14:09:32.000Z","updated_at":"2015-05-12T17:03:55.000Z","dependencies_parsed_at":"2022-09-15T21:01:57.119Z","dependency_job_id":null,"html_url":"https://github.com/flanker/grape-hal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flanker%2Fgrape-hal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flanker%2Fgrape-hal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flanker%2Fgrape-hal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flanker%2Fgrape-hal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flanker","download_url":"https://codeload.github.com/flanker/grape-hal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248731425,"owners_count":21152819,"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":"2025-01-22T23:16:15.571Z","updated_at":"2025-04-15T18:41:36.277Z","avatar_url":"https://github.com/flanker.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Grape Hal\n=========\n\nDescription\n-----------\n\nA ruby gem which adds HAL support to ruby Grape Api.\n\nHAL\n---\n\nHAL is a simple format that gives a consistent and easy way to hyperlink between resources in your API. See [HAL (Hyperlink Application Language)](http://stateless.co/hal_specification.html)\n\nRuby Grape\n----------\n\ngithub: [ruby grape api](https://github.com/intridea/grape)\n\nInstallation\n------------\n\nInstall the gem by:\n\n    gem install grape-hal\n\nOr add the gem to your Gemfile\n\n    gem 'grape-hal'\n\nUse it in code by\n\n    require 'grape/hal'\n\nExamples\n--------\n\nIf you want to add Hal response to your exist Grape Api, just simply include `Grape::Hal` and then use the dsl to describe your Apis.\n\nHere are some Grape Apis. Note the `include Grape::Hal` and `hal_for` block.\n\n```ruby\nrequire 'grape/hal'\n\nclass FooApi \u003c ::Grape::API\n  desc 'foo api description', rel: 'foo api'\n  get '/foo_path/'\nend\n\nclass SubApi \u003c ::Grape::API\n  desc 'bar api description with {param}', rel: 'bar api'\n  get 'bar_path/:param'\n\n  desc 'qux api description', rel: 'qux api'\n  get 'qux_path'\nend\n\nclass BazApi \u003c ::Grape::API\n\n  include Grape::Hal\n\n  mount FooApi\n  mount SubApi\n\n  hal_for '/' do\n    hal_for '/sub', rel: 'sub', title: 'a sub api module' do\n      mount SubApi\n    end\n    mount FooApi\n  end\n\nend\n```\n\nAfter this, when a http request to specific path with `json` format accept headers.\n\n    GET / HTTP/1.1\n    Accept: application/hal+json, application/json, */*; q=0.01\n\n`grape/hal` will response with the Hal data for you.\n\n    HTTP/1.1 200 OK\n    Content-Type: application/hal+json\n\n    {\n      \"_links\": {\n        \"self\": {\n          \"href\": \"/\"\n        },\n        \"sub\": {\n          \"href\": \"/sub\",\n          \"title\": \"a sub api module\"\n        },\n        \"foo api\": {\n          \"href\": \"/foo_path\",\n          \"title\": \"foo api description\"\n        }\n      }\n    }\n\nFooter\n------\n\nFeng Zhichao flankerfc(at)gmail.com\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflanker%2Fgrape-hal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflanker%2Fgrape-hal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflanker%2Fgrape-hal/lists"}