These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
REST model - best practice
  • I have a model making REST requests. Should the model "own" the url(s) or should the controller give the url to the model? There are several url/query string combinations, and I'm currently storing urls in the model and having the query args supplied by the controller. It doesn't feel right, though.

  • We did exactly that, and it does feel right; though the REST base url/domain is in a config file.
    (Is your REST service a Kohana app ?)

  • Yes, it's all Kohana. I did consider a config file, but the model would have to know which url to ask the config file for. So if the principle of model knowing url is wrong, it would just be differently wrong with a config file.

    Maybe I should settle for "if it works, don't fix it".

  • Did you base your REST app on samsoir/krestful, though it's no longer developed, or write your own?

  • I took the basic architecture from "Sleepy" - https://github.com/iammerrick/Sleepy#readme, and hacked around a lot of it.

    I'm only running it on my development version, though. I'm not a big fan of my own hacks....

  • If the model was to access a database, e.g. mysql, would the model provide the user name and password or would that be passed from a controller?

    Since the model would have ownership of database (or in your case, data) access it would be the model's responsibility to provide that information. If the controller was to provide this information you would have a dependency between your model and your controller which doesn't sound favorable.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion