unslash

Version, currently 0.1.03 versions

github.com/GrottoPress/unslash

A Crystal HTTP Handler to remove trailing slashes from URLs

0 stars
0 dependents
License: MIT

Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  unslash:
    github: GrottoPress/unslash
    version: ~> 0.1.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

Unslash

Unslash is a Crystal HTTP handler that removes slashes (/) at the end of URLs, performing a redirect to the unslashed version of the same URL.

This, among others, improves SEO by avoiding duplicated content across the different versions of the same URL.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      unslash:
        github: GrottoPress/unslash
  2. Run shards update

  3. Require Unslash:

    # ...
    require "unslash"
    # ...

Usage

Pass an instance of Unslash::Handler to the web server. If using a web framework, this handler should be passed before the framework's route handler:

# ...
require "http/server"
require "unslash"

server = HTTP::Server.new([
  # If `safe` is `true`, only `GET` and `HEAD` request methods
  # are handled.
  Unslash::Handler.new(status_code: 308, safe: false),
  # ...
])

server.bind_tcp("127.0.0.1", 8080)
server.listen
# ...

Development

Run tests with crystal spec.

Contributing

  1. Fork it
  2. Switch to the master branch: git checkout master
  3. Create your feature branch: git checkout -b my-new-feature
  4. Make your changes, updating changelog and documentation as appropriate.
  5. Commit your changes: git commit
  6. Push to the branch: git push origin my-new-feature
  7. Submit a new Pull Request against the GrottoPress:master branch.