-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API skeleton for revel new
cmd
#120
Comments
Can you provide (more of) an example of what you're thinking of? |
More and more web site need support restful api for developer, so I think maybe those web site project should be split into api server and ui server , like next: So the developing flow is: In order to develop api server and ui server in the same time, a fake api server should be a good idea. |
The api server do not need public directory, maybe do not need templates, do not need to know html, css, javascript, ajax, It will better for integration test, performance test, etc. |
@hfeeki so you want a way to create a Revel app from the command line that does not use HTML templates or public assets and that simply returns JSON/XML/etc serialized responses based on model structs and their validation rules with a RESTful GET/POST/PUT/PATCH/DELETE approach? It seems to me that this is already quite possible. Just create a new app with no templates or static public assets. It seems we would want to do some things to generate scaffolded routes, controller classes and model structs based on a database schema to automate the monotonous/repetitive steps to initial setup. Perhaps that is waht you're really asking? @robfig Do we have enough information here to mark this as contributor ready? |
@wanli2011 I've always enjoyed that article ever since I found it. REST can be a very controversial topic when it comes to "best practice". Anything specific you from this article you want to discuss? As far as this request goes, I can see some value in having some resource generation similar to rails for models, views, controllers, etc. Does anyone else have any input or insight on this? |
I think this would be an excellent feature. Some way to easily generate scaffolding would be very cool. Maybe providing various struct types that people could combine to compose API controllers. I don't know that this could be totally automated, there would have to be some explicit work in regard to data, since Revel really has no opinion in regard to models and data. Users would at least have to implement the code to perform the CRUD operations, since someone could be using any number of things.. the database/sql package, an ORM like Gorp, or some NoSQL solution. |
@iamjem standard models are a must for this feature to be implemented since you can't do much of an API without having CRUD access to data somewhere. We've discussed the options, but Go is different that other web capable languages in how data can be modeled, extended and serialized. There are also competing ideas of what the "Go way" of doing data abstraction is. For example, many Gophers strongly dislike the idea of ORM due to the object/relational mismatches that inevitably occur when interfacing the two. That, though, leads to a very sadistic/purist approach of working at a low level with the data (e.g. pure SQL queries) instead of gaining the benefits of abstraction. For commentary on the topic, you may enjoy http://blog.codinghorror.com/object-relational-mapping-is-the-vietnam-of-computer-science/ There is still value here in this feature request, but we need to discuss it more and make a decision on how to approach data modeling in Revel first. I've tagged this issue accordingly. |
My comment was more that an API in Revel doesn't need to be responsible for the CRUD operations, or know any specifics about the data layer of the application period. Instead its job could just be sanitizing and validating incoming and outgoing data. Maybe it just provides the hooks for the user to implement CRUD operations, handing them a neat bundle of "clean" data to work from. Revel certainly needs to know what the data should look like, and thats where I think there's some opportunities. It would make sense to evaluate how popular data packages in Go are handling modeling so that Revel could follow closely in line, allowing users to potentially re-use parts of the models they're already creating. |
Revel will provide the CRUD actions in the controller, right? One big issue is that because there are different data abstraction packages in common use, there is no single approach to support. The most generic is simply using |
It could start by supporting the most commonly used approach, then expanded afterwards. This feature would be useful for rapid development & to kickstart a project. |
@eddiejaoude I agree it would be useful at reducing the effort needed to get a project off the ground. Let's explore this more in v0.13. |
@brendensoares sounds good.
If not the most commonly, may be the recommended approach? |
@eddiejaoude Check out v0.14 of The New Roadmap. |
👍 |
Could you give me a starting point on where to implement such a thing? I have been trying to build a REST API around revel. I think we need global errors (or better anything) rendered as JSON or any data type supported by the API. I.e controller.RenderError should know what type to render based on content-type.. I am not sure how to approach but it would be great to help develop a solution. |
How can I pass RenderArgs to the controller? |
Check out progress on this topic here: https://github.com/kishorevaishnav/revelgen |
@PatrickWolleb feel free to join us on IRC to ask any questions. Where are you trying to pass As far as detecting content type per request, I think that's a good idea and deserves its own issue: #778. |
Gojsonschema Description |
revel new
cmd
@jniltinho that's a nice tool ,but we can't include that in the scope of Revel itself. TODO
Requirements (WIP)
Tests (WIP)
|
Should be re-assigned to revel/cmd enhancement |
Maybe RAML fits in here also #968 |
Closed and moved to revel/cmd revel/cmd#73 |
Fix DefaultValidationKeys generated with wrong line for multiline check
I think a pure json rest api server will be needed by many user.
And a fake api server also needed.
The text was updated successfully, but these errors were encountered: