{"id":27874361,"url":"https://github.com/akito19/rack-joint","last_synced_at":"2025-10-24T17:04:28.033Z","repository":{"id":52123282,"uuid":"146097428","full_name":"akito19/rack-joint","owner":"akito19","description":"Rack::Joint is a rack middleware to set redirect configuration with Ruby DSL.","archived":false,"fork":false,"pushed_at":"2023-01-27T15:11:06.000Z","size":41,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-10T08:04:17.224Z","etag":null,"topics":["middleware","rack","rack-middleware","ruby","rubygem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/akito19.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-25T13:26:37.000Z","updated_at":"2022-06-26T03:22:23.000Z","dependencies_parsed_at":"2023-02-18T03:05:13.836Z","dependency_job_id":null,"html_url":"https://github.com/akito19/rack-joint","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/akito19/rack-joint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akito19%2Frack-joint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akito19%2Frack-joint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akito19%2Frack-joint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akito19%2Frack-joint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akito19","download_url":"https://codeload.github.com/akito19/rack-joint/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akito19%2Frack-joint/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263628960,"owners_count":23491086,"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":["middleware","rack","rack-middleware","ruby","rubygem"],"created_at":"2025-05-05T01:33:12.429Z","updated_at":"2025-10-24T17:04:22.981Z","avatar_url":"https://github.com/akito19.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rack::Joint\n\nRack::Joint is a [Rack](https://github.com/rack/rack) middleware which helps to redirect with Ruby DSL.\n\n### Requirements\nRack::Joint requires Ruby 2.4+.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rack-joint'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rack-joint\n\n## Usage\n\nWrite settings in `config.ru`. This is a sample:\n\n```ruby\n# config.ru\nrequire 'rack/joint'\n\nuse Rack::Joint do\n  host 'example.com' do\n    # If you access `http://example.com/dogs/bark.html`,\n    # redirect to `http://example.org/bowwow.html` with 301.\n    redirect '/dogs/bark.html' do\n      new_host 'example.org'\n      to '/bowwow.html'\n      status 301\n    end\n\n    # If you access `http://example.com/cats.html`,\n    # redirect to `https://example.org/meow/mew` with 302.\n    redirect '/cats.html' do\n      new_host 'example.org'\n      ssl true\n      to '/meow/mew'\n      status 302\n    end\n  end\n\n  host 'example.net' do\n    # If you access `http://example.net/frog.html`,\n    # redirect to `http://example.net/croak` with 301.\n    redirect '/frog.html' do\n      to '/croak'\n    end\n\n    # If you access `http://example.net/quack`,\n    # redirect to `http://example.org/quack` with 301.\n    redirect '/quack' do\n      new_host 'example.org'\n    end\n  end\n\n  # Following description allows you to redirect to URL you set with only host replaced.\n  #\n  # e.g. When accessing 'http://example.io/foo/bar/baz',\n  #      redirect to `http://example.org/foob/bar/baz` with 301.\n  host 'example.io' do\n    redirect do\n      new_host 'example.org'\n    end\n  end\nend\n\nrun lambda { |env| [200, {'Content-Type' =\u003e 'text/plain'}, ['Hello World!']] }\n```\n\nYou can use following resources with block.\n\n| Resource | Type | Description |\n| :------- | :--- | :---------- |\n| `host`   | `string` | Required. Host name. |\n| `redirect` | `string` | Path name. If you give nothing with this option, Rack::Joint will replace only host name. |\n| `ssl` | `boolean` | Whether to enable SSL. If the option isn't set, the scheme of `Location` header is determined in response to GET request. |\n| `new_host` | `string` | A new host name redirects to. |\n| `to` | `string` | A new path name redirects to. |\n| `status` | `integer` | Status when redirecting. You can use `301`, `302`, `303`, `307`, `308`; which is `301` to default. |\n\n#### Supplement\n\n[This library's test case](https://github.com/akito19/rack-joint/tree/master/test/config) will be actual samples.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/akito19/rack-joint.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakito19%2Frack-joint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakito19%2Frack-joint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakito19%2Frack-joint/lists"}