4 ms·
one my wonder about what could this be: > routes" (procedures, mapped to URL patterns, that execute logic such as accessing models (cached or queried) A "rout
by gls2ro 3y ago
one my wonder about what could this be:
> routes" (procedures, mapped to URL patterns, that execute logic such as accessing models (cached or queried)
A "route" that executes logic such as accessing models responding with an output based on what mime type was requested, can set a layout or template for the view ...
changing the name to "route" does not change the pattern that you are implementing here.
Rails Controllers are doing exactly everything that you describe here with the only exception that there is a big table that keeps references between a URL and the controller method associated with that URL.
I am not saying Rails is better than what you build, but just noticed that a lot of what you describe as a "route" is matching what a controller is doing.
- adamrezich 3y agoit's been a very long time since I did anything with Rails… but I recall there being Ruby code in the "Views", which is something I'm choosing to avoid entirely. all logic is executed in the "Route" (or whatever it's called in the end) procedure, which is where, if you want to output HTML, you invoke a "Render" macro that takes in the template name and optionally any variables you want to pass in. the HTML templates have a simple, Mustache-like syntax (insert parameter, insert nested template/"partial"), but it's just plain HTML with some {{placeholdery-looking stuff}}. maybe I'll add a JSON "renderer" if I need it, and I still need to get static file loading to work, but other than that, this framework does pretty much everything I want to do as far as website backends go, and it compiles to a single executable. it's not going to be The Future Of Web Development, but it will be nice (for me at least) to make small-to-medium-sized websites with, in large part because it's much easier for me to reason about "Models (structs), Routes (code), Templates (HTML)" than "MVC", or at least, how I remember "MVC" feeling in Rails, and Django.