Git Product home page Git Product logo

rack-unpoly's Introduction

Unpoly for Rack & Sinatra

Installation

Add this line to your application's Gemfile:

gem "rack-unpoly"

And then execute:

$ bundle

Or install it yourself as:

$ gem install rack-unpoly

Usage in a Rails application

Use the official Unpoly gem from Makandra.

Usage in a Sinatra application

require "sinatra/base"
require "sinatra/unpoly"

class App < Sinatra::Base
  register Sinatra::Unpoly

  get "/" do
    if up?
      "Unpoly request!"
    else
      "Not Unpoly :("
    end
  end
end

Usage in a Roda application

Use the roda-unpoly gem.

Usage in a Rack application (that's not Rails, Sinatra, or Roda)

require "rack"
require "rack/unpoly/middleware"

use Rack::Unpoly::Middleware

app = ->(env) {
  if env["rack.unpoly"].up?
    [200, {}, ["Unpoly request!"]]
  else
    [200, {}, ["Not Unpoly :("]]
  end
}

run app

Where are the Javascript and CSS assets?

I've chosen not to bundle those assets with the gem as they might be updated more frequently then this library. Most Ruby web libraries outside of Rails are asset-agnostic (for the most part), so it's easier if you bring in your assets as you see fit for your specific needs.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/adam12/rack-unpoly.

I love pull requests! If you fork this project and modify it, please ping me to see if your changes can be incorporated back into this project.

That said, if your feature idea is nontrivial, you should probably open an issue to discuss it before attempting a pull request.

License

The gem is available as open source under the terms of the MIT License.

rack-unpoly's People

Contributors

adam12 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sztheory

rack-unpoly's Issues

X-Up-Location header should not be sent by default

The middleware of this gem automatically echoes the request URL in an X-Up-Location response header. I recommend removing this feature.

Echoing the request URL was needed to detect the final URL after a redirect in legacy browsers, namely Internet Explorer 11. Now that IE11 is finally dead, this is no longer necessary.

Also reflecting the user-controlled request URL can lead to a Denial of Service issue in particular server setups.

Thank you for maintaining this package!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.