{"id":15838130,"url":"https://github.com/gamemaker1/http-negotiator","last_synced_at":"2026-02-09T07:09:51.783Z","repository":{"id":115225884,"uuid":"394988523","full_name":"gamemaker1/http-negotiator","owner":"gamemaker1","description":"A HTTP content negotiator for V","archived":false,"fork":false,"pushed_at":"2021-08-13T13:54:29.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-06T13:48:20.451Z","etag":null,"topics":["content-negotiation","http","v","v-module","vlang","vlang-module"],"latest_commit_sha":null,"homepage":"","language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gamemaker1.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-11T12:55:19.000Z","updated_at":"2021-11-14T17:20:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"992b71b5-a2d0-4cd4-887a-1d462815af70","html_url":"https://github.com/gamemaker1/http-negotiator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gamemaker1/http-negotiator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fhttp-negotiator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fhttp-negotiator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fhttp-negotiator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fhttp-negotiator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamemaker1","download_url":"https://codeload.github.com/gamemaker1/http-negotiator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemaker1%2Fhttp-negotiator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29258627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T04:11:57.159Z","status":"ssl_error","status_checked_at":"2026-02-09T04:11:56.117Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["content-negotiation","http","v","v-module","vlang","vlang-module"],"created_at":"2024-10-05T16:00:38.294Z","updated_at":"2026-02-09T07:09:51.767Z","avatar_url":"https://github.com/gamemaker1.png","language":"V","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTTP Negotiator\n\nA HTTP content negotiator for V that allows you to parse the `Accept` header of an HTTP request and get the preferred response media type specified by the client.\n\n## Usage/Examples\n\nFirst, download the library:\n\n```\nv install --git https://github.com/gamemaker1/http-negotiator\n```\n\nThen use it:\n\n```v\n// Import the library\nimport gamemaker1.http_negotiator\n\n// You need to get this value from the request object\n// In this case, since it is an example, this value is hard-coded\n// This value in an `Accept` HTTP header means that the client would like a\n// response:\n// - in the `application/json` format first\n// - if that's not available, give it in the `text/plain` format\n// - if that's not available, we're fine with anything\n// The `q` paramter stands for `quality`, which indicates how much the client\n// favours that response media type (0 is least, 1 is most; default is 1).\naccept_header_value := 'application/json;charset=utf-8, text/plain;q=0.9;charset=utf-8, text/html;q=0.8;charset=utf-8, */*;q=0.7'\n// Which media types you (the server) can respond in\npossible_media_types := ['text/html', 'application/json']\n\n// Now the library allows you to get:\n// 1. a list of response media types in order of client's preference\n// 2. the most preferred media type that the client wants\n\n// For 1:\npreferred_media_types := http_negotiator.get_media_types(\n\t// The `Accept` header passed by the client\n\taccept_header_value,\n\t// Valid media types that you can respond in\n\tpossible_media_types\n) or {\n\t// If:\n\t// - none of the client's accepted media types can be provided by the server\n\t// - a media type provided by the client is an invalid one\n\t// Then: use 'application/xml' by default\n\t'application/xml'\n} // Returns ['application/json', 'text/html']\n\n// For 2:\npreferred_media_type := http_negotiator.get_media_type(\n\t// The `Accept` header passed by the client\n\taccept_header_value,\n\t// Valid media types that you can respond in\n\tpossible_media_types\n) or {\n\t// If:\n\t// - none of the client's accepted media types can be provided by the server\n\t// - a media type provided by the client is an invalid one\n\t// Then: use 'application/xml' by default\n\t'application/xml'\n} // Returns 'application/json'\n```\n\nAn example with VWeb can be found in [`examples/vweb.v`](/examples/vweb.v)\n\n## Issues/Contributing\n\nThank you for using this library. Please feel free to open an issue to report a bug or suggest something. PRs are also welcome!\n\n## License\n\nThis project is licensed under the ISC license. View the [license file](/license.md) for more details.\n\nCopyright 2021 Vedant K (gamemaker1) \\\u003cgamemaker0042 at gmail dot com\\\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemaker1%2Fhttp-negotiator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamemaker1%2Fhttp-negotiator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemaker1%2Fhttp-negotiator/lists"}