GithubHelp home page GithubHelp logo

Plug into middleware? about grape HOT 5 CLOSED

seivan avatar seivan commented on May 14, 2024
Plug into middleware?

from grape.

Comments (5)

benschwarz avatar benschwarz commented on May 14, 2024

You don't need to use rails3 routes. Grape is a rack application and should be loaded alongside your rails application.

Stick something like this in your config.ru

run Rack::Cascade.new([
   YourAppname::Application,
   YourAppname::API
])

from grape.

seivan avatar seivan commented on May 14, 2024

Cool, how would that work with using models and helpers and how would the routes look like?

from grape.

benschwarz avatar benschwarz commented on May 14, 2024

Forget routes!

This is a rack middleware that constructs its own routes using the DSL (much like a sinatra application would).

Perhaps you should create a pretend API outside of your rails application to better understand how middleware works.

from grape.

seivan avatar seivan commented on May 14, 2024

Yeah I figured that out. But how would interacting with Rails models, gems and helpers work.
Could it share the Gemfile with a rails application? Could I plug in Devise into it?

from grape.

benschwarz avatar benschwarz commented on May 14, 2024

If you keep it within your rails application, and load it alongside the rails environment (also add it to your config.ru) you'll have access to the core classes (your models).

Devise would just sit over the top—although I'd look into the authenticated examples that are in the sinatra demo app that intridea created for you :)

from grape.

Related Issues (20)

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.