Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Modifying Headers in Server Is Messy

#11

There should be a cleaner way to modify headers (for all requests) and for specific requests. For instance, perhaps it should just be a class method like this:

class Foo < Halcyon::Server::Base
  headers :on => [:foo, :bar] do |req|
    req['Header-Field'] = 'Value'
    req
  end
end

Specifically with the Basic Authorization, it should only attempt authentication on actions that need it.

class Foo < Halcyon::Server::Auth::Basic
  basic_authorization :on => [:foo, :bar] do |user, pass|
    [user, pass] == ['rupert', 'secret']
  end
end

Reported by Matt Todd · January 21st, 2008 @ 12:00 AM

State: resolved
Milestone: Release 0.4.0
Assigned to: Matt Todd Matt Todd

Activity

  1. Matt Todd
    Matt Todd
    • State changed from new to open

    Fixed the clumsiness of the basic_authorization call, implementing almost exactly the example above. Instead of basic_authorization, the method is now called basic_auth, and it now accepts options for only certain actions or all except a few, though by default it requires basic authorization for all actions.

    For example:

    class Foo < Halcyon::Server::Auth::Basic
      basic_auth :only => [:foo, :bar] do |user, pass|
        [user, pass] == ['rupert', 'secret']
      end
    end
    

    February 5th, 2008 @ 12:13 PM

  2. Matt Todd
    Matt Todd
    • State changed from open to resolved

    For now, this should be sufficient since, when performing requests, you can easily supply additional headers.

    For example.

    get('/foo/bar', {'X-Special-Header' => 'value'})
    

    This will be reevaluated in 0.5.0 when the server and client internals have been restructured for more elegant options for whole-application header values or callbacks allowing quick modification before being sent, but this will be sufficient for now.

    February 10th, 2008 @ 10:12 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.