http_method_emulator
Version, currently 0.1.01 version
- 0.1.0latestJan 4, 2019
github.com/imdrasil/http_method_emulator
Simple HTTP method emulator for form submitted data.
Installation
# Add this to your shard.yml
dependencies:
http_method_emulator:
github: imdrasil/http_method_emulator
version: ~> 0.1.0Then run:
shards installshard.yml
- Crystal
0.27.0- License
- MIT
- Author
- Roman Kalnytskyi
Dependencies
This version declares no dependencies.
README
http_method_emulator
Simple HTTP method emulator for form submitted data.
Installation
- Add the dependency to your
shard.yml:
dependencies:
http_method_emulator:
github: imdrasil/http_method_emulator
- Run
shards install
Usage
HTML form supports only GET and POST method. To bring other methods support you can use this shard. This shard will be useful for a web frameworks/libs that have no such functionality (like Kemal or Spider-Gazelle).
require "http_method_emulator"
# Add handler to your middlewares
# like for Kemal
add_handler HTTPMethodEmulator::Handler::INSTANCE
Also require "lib/http_method_emulator/assets/http_method_emulator.js" in your js assets.
Now you can just create POST form with hidden field _method holding required method.
<form method="POST" action="/some/path">
<input type="hidden" name="_method" value="PATCH">
<button type="submit">Make Request</button>
</form>
JS catches submit event and add query parameter based on form _method field (or do nothing if it isn't exist). Handler modifies POST request method setting value sent in query _method field.
Configuration
You can specify field name to be used for holding method name. This should be done in two places - crystal and JS.
HTTPMethodEmulator.config do |conf|
conf.key = "http_method"
end
// Anywhere after js being imported
window.HTTPMethodEmulator.key = "http_method"
Contributing
- Fork it (https://github.com/imdrasil/http_method_emulator/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
- Roman Kalnytskyi - 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
- Jan 4, 2019
- Commit
2d4e723ca58e- Crystal
0.27.0- Indexed
- yes
Dependents
Repository
github.com/imdrasil/http_method_emulator
Metadata
- Created
- Aug 16, 2026
- Updated
- Nov 14, 2026
- Synced
- Nov 14, 2026
- Versions
- 1