danmaclean / gee_fu

An extensible Ruby on Rails web-service application and database for visualising HTGS data
18 stars 5 forks source link

Add middleware for AnnoJ parsing #14

Closed mrship closed 11 years ago

mrship commented 11 years ago

I reviewed the AnnoJ calls and realised that part of the problem is that it uses the reserved Rails param 'action' to specify what it wants to happen, i.e. range or lookup for example.

Rails strips the action parameter and injects its own that reflect that actual Rails action that is being called in the controller.

This PR adds some Rack middleware that intercepts the request and injects a annoj_action param that reflects the original request by AnnoJ. As such we can clean up the features_controller code significantly as there's no need for custom param parsing, i.e.:

    case params[:annoj_action]
      when "range" 
        @response = range(params['assembly'], params['left'], params['right'], params[:id], params['bases'], params['pixels'])
      when "lookup"
        @response = lookup(params["query"], params[:id])
    end
    render :json => @response, :layout => false

Much cleaner.

mrship commented 11 years ago

@danmaclean Forgot the spec, which meant I forgot the GET clause which means I need to not forget the spec!