Comments (6)
I'm the guy who originally wrote Reststop, and to be honest I don't particularly like writing out the resource name twice when defining a restful controller or having to explicitly write out obvious XML views. It's been a while since I've even looked at this code (~2 years) but if I recall correctly a lot of these design decisions were made because of certain constraints in the way Camping does things. I can't remember my reasons exactly, but I do remember being pretty frustrated the entire way through. If it were up to me, Reststop's functionality would be incorporated into Camping's core. This could make the syntax for doing things restfully a lot more flexible.
I do understand though why Magnus is reluctant to do this. We had a conversation about this a while back. What he likes about Camping is it's minimalism, and incorporating major changes like this into the core could really screw with what Camping is all about (for him, anyway).
But doing what you're asking, in my experience, would be too awkward without making changes to Camping itself. I don't think you're going to see this functionality without some big refactoring.
from camping.
I think zuk expresses my opinion better than I can :-)
I do understand though why Magnus is reluctant to do this. We had a conversation about this a while back. What he likes about Camping is it's minimalism, and incorporating major changes like this into the core could really screw with what Camping is all about (for him, anyway).
But of course: If that's what the Camping community want, that's what the Camping community will get. Both of you are owners of the Camping organization on GitHub and are free to commit whatever you like (in the same way as I do), but I would of course strongly recommend asking around before committing anything as big as this.
Well, as long as Camping stays at 4k, I think such a RESTful-feature would do no harm. How we're going to get it in under 1k (and still be useful) is beyond my imagination…
from camping.
the size constraint is easy. we just use autoload. i don't care for the cheating, but we do it crazy much as it is. I mean all of our ActiveRecord stuff is autoloaded.
from camping.
The thing about the database and template layer is that it's very much replaceable parts. It's only there for integrating with other libraries. But anyway: If it can be implemented with autoload, it can also be implemented in a separate project.
from camping.
From my perspective I feel that the definition of REST routes belong to the controller as opposed to the model. The model should remain about the data and persistence I think.
That said we could improve the syntax: what about giving the controller a simple base class (REST)? This would eliminate the repetition on the controller declaration.
For the views we could use some conventions to auto-render using the format corresponding to the declared view module (e.g. XML,JSON, etc).
What do you think?
from camping.
I know this thread is 12 years old but I don't like the idea of making Models in charge of endpoints. Having explicit Views that render Json is a good abstraction to have.
I agree with what @techarch has said.
Often times REST APIs also have authentication requirements or visibility restrictions on the data. That's one reason we have the controllers in the first place, to gate actions with logic. Broad gates or transformations happen via middleware.
But having an extension to Views to specify the type of Data being Rendered is a good idea. This probably doesn't need to be an explicit extension, but something that can be patched in. We could outline the method and it's use cases in a guide and then recommend that guide when someone wants to have REST endpoints.
from camping.
Related Issues (20)
- New Spec for Routing HOT 14
- Add Zeitwerk Autoloading, Establish loading procedure.
- How to return return json and pdf. HOT 1
- Camping Audit
- Write Config.kdl guide
- Use KDL as the settings/config file thingy HOT 1
- Add Rack 3.0 Linter to Tests
- Officially support Windows again
- Write Tests for generator HOT 1
- Rename Master Branch to Main (Again) HOT 1
- Fix Reloader HOT 3
- Gem dependencies are not fully documented in the ReadMe HOT 11
- Camping Server isn't Properly Tested.
- Add simpler DSL support for straight up mapping requests to a camping app.
- Add Markaby back as a dependency
- Add RAKE task to release new gem
- Make passkeys the default authentication option HOT 2
- Getting error when trying out camping book section 02 on models HOT 1
- RubyGems page still lists camping.rubyforge.org as homepage HOT 5
- Sub directories in Apps won't let you redefine URLs without being sad
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from camping.