Comments (3)
How exactly do you intend to send a struct
in URI? Would you please send and example input?
from goyave.
@MShoaei
Let's say we have a Product
struct model. The idea behind this would be to declare a route like this:
router.Get("/product/{Product}", product.Show, nil)
A request to show the Product with the ID (primary key) "4" would be:
GET /product/4
The framework would do something like this:
product := model.Product{}
database.GetConnection().First(&product, request.Params["Product"])
// Override the raw parameter with the struct
request.Params["Product"] = product
This is just a draft, and that would require the request.Params
map to be changed to a map[string]interface{}
, which is not ideal, but hopefully you get the idea.
The motivation behind this is that retrieving data from the database is not part of the business logic so it shouldn't be done inside the controller handler. Also, this would reduce redundancy because you currently have to write this kind of code in almost every controller handler.
from goyave.
I prefer to ditch this idea. It is already easy enough to retrieve the model.
from goyave.
Related Issues (20)
- Http Client for goyave HOT 6
- response.Error() doesn't take response status into account in debug mode
- Validation made for autocomplete HOT 3
- Exists/Unique validation rule panics when input type doesn't match database column type HOT 1
- Panic when parsing multipart form with an empty file HOT 1
- Clickhouse database dialect HOT 2
- Bigquery database dialect
- Deflate compression encoder HOT 1
- LZW compression encoder
- Brotli compression encoder
- Zstd compression encoder
- New validator: KeysIn
- New validator: DoesntStartWith
- New validator: DoesntEndWith
- Language variant priority is not deterministic
- walk.Path escape character
- Validation of config struct and slice HOT 1
- Validation: use default language if not provided HOT 1
- http.Flusher implementation
- Respond with message for unclear status codes
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 goyave.