Questions tagged [rack]

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Rack is a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.

Useful Links

1617 questions
0
votes
1 answer

Wrong number of arguments on Rack::Builder.new

I apparently have a Rack::Builder misunderstanding. Inside my config.ru file i've got: require 'rack' require 'rack/lobster' class Shrimp SHRIMP_STRING = 'teste' def initialize(app) @app = app end def call(env) status,…
paulorcdiniz
  • 164
  • 1
  • 10
0
votes
1 answer

How can I rewrite a subdomain to another subdomain?

I have this simple rack middleware written to rewrite my subdomain : def call(env) request = Rack::Request.new(env) if request.host.starts_with?("something-something") [301, { "Location" =>…
Trip
  • 26,756
  • 46
  • 158
  • 277
0
votes
1 answer

url rewrite strip slashes unless a hashbang precedes

I'm using rack-rewrite to add a url rewrite rule that will strip slashes, but I only want it to do it if there isn't a hashbang following the slash. I tried the following regex, but it rewrites anyway, even if there is a #! after the…
Roland
  • 9,321
  • 17
  • 79
  • 135
0
votes
1 answer

Get actual encoded url in Sinatra handler, splat broken

How do I get the actual encoded URL that was passed to my handler in Sinatra? I have a url like - note there is / followed by a double slash that's encoded.. http://someplace.com/thing/blah/%2F%2Fxxx.png get '/thing/*/*' do begin #…
Tom Andersen
  • 7,132
  • 3
  • 38
  • 55
0
votes
1 answer

How to call a ruby script from webpage and output the results?

Okay so maybe you guys can advise me. Here is what I am attempting to do. I am trying to call my ruby script from a html form on a website that has already been created. The form needs to pass a variable entered in a text box to the ruby…
user3427228
  • 25
  • 1
  • 5
0
votes
1 answer

Separate files for Ember handlebars templates in a Middleman App

I have multiple Ember apps that live in a Middleman app. The current directory structure is [app-name] components helpers source assets img css js // jQuery for other pages app.js // An ember app …
Sam Selikoff
  • 12,366
  • 13
  • 58
  • 104
0
votes
1 answer

How to use puma in production mode by set production environment?

I made a little Sinatra app. In my Gemfile add gem 'puma' in the production group group :production do gem 'puma' gem 'dm-postgres-adapter' end And I set production mode in config.ru set :environment, :production But after I run backup,…
mko
  • 21,334
  • 49
  • 130
  • 191
0
votes
1 answer

Sinatra app (potentially) calling database twice

I'm encountering a rather weird problem. I have the following test in one of my routes: error 404 unless Agreement.find_by(agreement_id: params[:agreement_id]) This is an active record model, and I just use the provided find_by method. When I…
nicohvi
  • 2,270
  • 2
  • 28
  • 42
0
votes
1 answer

Shrimp/PhantomJS page size

I've got a Rails 4 Shrimp solution that is putting out PDFs successfully via middleware. The only problem I have is that I need to control the size of the PDF page so that it can change each time. Is that possible, or what do I need to do…
Snaga
  • 18
  • 5
0
votes
1 answer

Rspec testing API with rack protection

I am trying to test my API with an rspec integration(request) test. I go to my api endpoint at 0.0.0.0:3000/api/regions in a browser and it returns my data, I get a session id and looks like everything is working. I am using rack protection in my…
Stan Bondi
  • 4,118
  • 3
  • 24
  • 35
0
votes
1 answer

How to detect mobile phone from http request using rack middleware

I have a rails app and I am using rack-mobile-detect to provide different responses to mobile phones. Now I am trying to cache these responses and the problem is that rack-mobile-detect tags tablets as well as phones so I can't key on the…
laertiades
  • 1,992
  • 2
  • 19
  • 26
0
votes
2 answers

Rack: Why is each middleware called twice on a single request?

I'm trying to understand how Rack works, and I'm testing out an example from this rack tutorial. The example creates a "hello world" rack app, as well as two trivial pieces of middleware, and then runs them all: Example Rack App With Middleware This…
Jonah
  • 15,806
  • 22
  • 87
  • 161
0
votes
1 answer

"accessorize" method - Ruby, Rack or Sinatra?

I've seen the following idiom, and wonder what does accessorize mean and where does it come from - Ruby, Rack or Sinatra? use Rack::Flash, accessorize: [:error, :success]
Arman H
  • 5,488
  • 10
  • 51
  • 76
0
votes
0 answers

ruby on rails - thin - HTTP GET URL > 1024

When I use an URL bigger than 1024 appear this in the console of the rails server. Invalid request: HTTP element REQUEST_PATH is longer than the 1024 allowed length. …
0
votes
1 answer

Ruby, Sinatra, Overriding/Extending a class from a separate file to add a method

I'm new to Ruby, I can find answers for various variations on this question but not an answer to my problem itself. I am writing an application which takes basic auth details and uses them to authenticate the user with a 3rd party platform as such I…
Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124