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

Session data not being saved in Sinatra simple authentication

I created a simple authentication for Sinatra, however the session object seems to be cleaning up ALL custom keys. For example, when user logs in: session[:user_id] = current_user.id This is effectively stored in the session object for the current…
ksiomelo
  • 1,878
  • 1
  • 33
  • 38
0
votes
1 answer

Sinatra middleware that converts params variable based on the CONTENT_TYPE header

I have an API endpoint that is supposed to receive either JSON or form urlencoded data. I can detect this by the accept header but I am just wondering if there is a rack middleware that does this for me already. Basically, it converts the parameter…
denniss
  • 17,229
  • 26
  • 92
  • 141
0
votes
1 answer

How to determine http status code in range error handler

What I'd like to do is: error 400..510 do {:'400' => 'Bad Request', :'401' => ...}[.to_s.to_sym] end where is some expression, evaluated to error code to be returned. One possible way the handler is…
x-yuri
  • 16,722
  • 15
  • 114
  • 161
0
votes
2 answers

rack-saml Assertion Consumer Service binding

I am using rack-saml as middleware with omniauth-shibboleth to allow my app to work as a Service Provider. I would like to know how to set the binding for an Assertion Consumer Service (ACS) url? Presently my ACS url binding is 'any'. However, I…
user2517182
  • 1,241
  • 3
  • 15
  • 37
0
votes
1 answer

Handling WebSocket connections in Rack

The readme for faye-websocket-ruby has the below example. What does the line of code p [:close, event.code, event.reason] do and what does p mean there? Also what does ws.rack_response do and why is it necessary? # app.rb require…
user782220
  • 10,677
  • 21
  • 72
  • 135
0
votes
2 answers

In Sinatra, is there a way to forward a request to another app?

I'm trying to do something like this: class Dispatcher < Sinatra::Base def initialize @foo = Foo.new end get '/foo/*' do @foo.call(params[:splat]) end end So that URL /foo/abc/def?xxx=yyy would be like calling the Foo app with…
Mathieu Longtin
  • 15,922
  • 6
  • 30
  • 40
0
votes
1 answer

Ruby/Rails library for DRYing up resource access

A common pattern in a Rails controller action is to Fetch a resource Do something to the resource (optional) Return the resource in a serialized format. I am looking for a library that abstracts away the first step, so that my controller actions…
rickyrickyrice
  • 577
  • 3
  • 14
0
votes
1 answer

How can Webrick based (Non RoR, Sinatra) web application can be severed using Apache and Passenger?

I have developed a small ruby web application using Webrick abstract servlet , File-handler and basic authentication. Now I want this application to be served using apache and passenger, what are the options available Do I need to remove Webrick…
giddy
  • 3
  • 1
0
votes
2 answers

host and port in a grape entity

Im trying to get the host and port in a grape-entity when generating an url class Person < Grape::Entity expose :url do |person,options| "http://#{host_somehow}/somepath/#{person.id}" end end I´ve tried examining the options hash…
Erik Johansson
  • 1,188
  • 1
  • 8
  • 22
0
votes
2 answers

Rack::Cache/Rack::Etag 304

I use Rack:Etag to genereate proper etag values based on the response from the server and for development I use Rack::Cache to verify that that caching I expect to happen really does But i have a slight predicament: I send a request and get these…
Rune
  • 631
  • 1
  • 5
  • 3
0
votes
1 answer

Why cookie doesn't work using Sinatra and Omniauth?

I need to change a cookie from "Session" type to "Persistent" type. Moreover I need to have it working together with "omniauth-facebook". In the example below everything is working well but when I use omniauth the cookie is not set at all. This is…
Lucamug
  • 792
  • 5
  • 19
0
votes
0 answers

Rack breaks bootstrap

I have a personal site I'm trying to deploy using rack to heroku. When I open the index.html file on my machine, everything looks and works fine. But when I use rackup to run it locally, all my Bootstrap styling is gone. Any idea what's going on…
Logan Shire
  • 5,013
  • 4
  • 29
  • 37
0
votes
2 answers

rack-affiliates gem with localhost

I'm messing with Rack::Affiliates but I don't know if it works with the domain localhost in development environment. 1º This is my config in application.rb file: config.middleware.use Rack::Affiliates, {:param => 'aff_id', :ttl => 6.months, :domain…
hyperrjas
  • 10,666
  • 25
  • 99
  • 198
0
votes
1 answer

A rack fix to lower version

I have to bring a fix that was made on rack 1.4.5 to my 1.36 rack. Can not upgrade rack as ruby is not happy with it Bundler could not find compatible versions for gem "rack": In Gemfile: sass-rails (~> 3.1.4) ruby depends on rack (~>…
0
votes
1 answer

How to capture size of an API response in Rails?

I want to capture the size of responses being made by the API of my Rails 3 app. The idea is that if a client application requests a resource, the full size of the JSON response (in KB/MB, after RABL renders it) can be captured and stored, so that I…
Michael
  • 683
  • 9
  • 21
1 2 3
99
100