http_accept
Version, currently 0.1.01 version
- 0.1.0latestApr 24, 2021
github.com/BecauseOfProg/http_accept
A library about parsing HTTP Accept-Language headers.
2 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
http_accept:
github: BecauseOfProg/http_accept
version: ~> 0.1.0Then run:
shards installshard.yml
- Crystal
1.0.0- License
- MIT
- Author
- Nicolas Martinussen
Dependencies
This version declares no dependencies.
README
HTTP::Accept
Provides parser for dealing with HTTP Accept-Language headers.
Inspired by Ruby http-accept gem
Installation
-
Add the dependency to your
shard.yml:dependencies: http_accept: github: BecauseOfProg/http_accept -
Run
shards install
Usage
require "http_accept"
# wanted_languages = HTTP::Accept::Language.parse("da, en-gb;q=0.8, en;q=0.7")
http_headers : HTTP::Headers
wanted_languages : Array(HTTP::Accept::Language::Value)? = nil
if http_headers["Accept-Language"]?
wanted_languages = HTTP::Accept::Language.parse(http_headers["Accept-Language"])
end
HTTP::Accept::Language.best_locale(["en", "fr"], wanted_languages) # => "en"
HTTP::Accept::Language.best_locale(["fr", "nl"], wanted_languages, "fr") # => "fr"
HTTP::Accept::Language.best_locale(["en", "fr"], nil) # => "en"
TODO: Write usage instructions here
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/BecauseOfProg/http_accept/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Nicolas Martinussen - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Apr 24, 2021
- Commit
358bd00ebbab- Crystal
1.0.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/BecauseOfProg/http_accept
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1