{"id":15491628,"url":"https://github.com/remi/plug_best","last_synced_at":"2026-01-18T01:35:22.195Z","repository":{"id":47583740,"uuid":"59663612","full_name":"remi/plug_best","owner":"remi","description":"PlugBest parses HTTP “Accept-*” headers and returns the best match based on a list of values.","archived":false,"fork":false,"pushed_at":"2021-08-23T09:45:09.000Z","size":60,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-17T22:17:08.236Z","etag":null,"topics":["elixir","http","language","localization","plug"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/plug_best","language":"Elixir","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/remi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-25T13:03:07.000Z","updated_at":"2023-09-01T10:50:21.000Z","dependencies_parsed_at":"2022-08-30T21:11:13.471Z","dependency_job_id":null,"html_url":"https://github.com/remi/plug_best","commit_stats":null,"previous_names":["remiprev/plug_best"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/remi/plug_best","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_best","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_best/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_best/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_best/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remi","download_url":"https://codeload.github.com/remi/plug_best/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remi%2Fplug_best/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28526552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"ssl_error","status_checked_at":"2026-01-18T00:39:39.467Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["elixir","http","language","localization","plug"],"created_at":"2024-10-02T07:54:42.019Z","updated_at":"2026-01-18T01:35:22.167Z","avatar_url":"https://github.com/remi.png","language":"Elixir","readme":"# PlugBest\n\n\u003ca href=\"https://github.com/remi/plug_best/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush\"\u003e\u003cimg src=\"https://github.com/remi/plug_best/workflows/CI/badge.svg?branch=master\u0026event=push\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://hex.pm/packages/plug_best\"\u003e\u003cimg src=\"https://img.shields.io/hexpm/v/plug_best.svg\" /\u003e\u003c/a\u003e\n\n`PlugBest` parses HTTP `Accept-*` headers and returns the best match based on a list of values.\n\n## Installation\n\nAdd `plug_best` to the `deps` function in your project's `mix.exs` file:\n\n```elixir\ndefp deps do\n  [\n    …,\n    {:plug_best, \"~\u003e 0.3\"}\n  ]\nend\n```\n\nThen run `mix do deps.get, deps.compile` inside your project's directory.\n\n## Usage\n\n`PlugBest` currently provides eight methods:\n\n- `best_language/2`\n- `best_language_or_first/2`\n- `best_charset/2`\n- `best_charset_or_first/2`\n- `best_encoding/2`\n- `best_encoding_or_first/2`\n- `best_type/2`\n- `best_type_or_first/2`\n\nTo find out which language is the best one to use among a list of supported languages:\n\n```elixir\nconn |\u003e Plug.Conn.get_req_header(\"accept-language\")\n# =\u003e [\"fr-CA,fr;q=0.8,en;q=0.6,en-US;q=0.4\"]\n\nconn |\u003e PlugBest.best_language([\"en\", \"fr\"])\n# =\u003e {\"fr-CA\", \"fr\", 1.0}\n```\n\nIf no values in the header is support, `PlugBest` will return the first `nil`. However,\nyou can use the `_or_first` suffix to make it return the first value in those cases.\n\n```elixir\nconn |\u003e Plug.Conn.get_req_header(\"accept-language\")\n# =\u003e [\"fr-CA,fr;q=0.8,en;q=0.6,en-US;q=0.4\"]\n\nconn |\u003e PlugBest.best_language([\"es\", \"ru\"])\n# =\u003e nil\n\nconn |\u003e PlugBest.best_language_or_first([\"es\", \"ru\"])\n# =\u003e {\"es\", \"es\", 0.0}\n```\n\n## License\n\n`PlugBest` is © 2016-2017 [Rémi Prévost](http://exomel.com) and may be\nfreely distributed under the [MIT license](https://github.com/remiprev/plug_best/blob/master/LICENSE.md). See the\n`LICENSE.md` file for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremi%2Fplug_best","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremi%2Fplug_best","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremi%2Fplug_best/lists"}