digitalmars.D.announce - Potcake Web Framework v0.2.0
- Kyle Ingraham (43/43) Jul 15 2023 I've been working on implementing some of the things I like about
I've been working on implementing some of the things I like about the Django framework from Python in D. It started out as a vibe.d router implementing Django's URL dispatching scheme (https://forum.dlang.org/thread/mhnchxsabvvriavwqntj forum.dlang.org). Now it's a web framework of its own (still powered by vibe.d): https://github.com/kyleingraham/potcake The latest release is setup for easy web app creation. Web apps can be created through two new objects, `WebApp` and `WebAppSettings`. Through them we provide the following features: - [Django-style routing](https://github.com/kyleingraham/potcake#url-dispatching) - [Static file serving](https://github.com/kyleingraham/potcake#static-files) (with collection of files from multiple directories) - [Django-style URL reversing](https://github.com/kyleingraham/potcake#url-reversing) - [Middleware](https://github.com/kyleingraham/potcake#middleware) - [Settings management](https://github.com/kyleingraham/potcake#settings) The URL dispatching has been revamped to provide an ergonomic API free of templates. Path parsing is now done at runtime which frees us from the struggles templates bring. Templates are great but use of them for central data structures forces user code to be templated. It also makes some API structures impossible to right. For example, with templates the user cannot store configuration as data prior to instantiating the WebApp if the configuration uses templates that need the WebApp. Also, each instantiation is a new type if the template arguments differ. This prevents storing template instantiations in a collection. Instead we make heavy use of delegates for storing code to use an object instead of objects themselves. This is handy for storing disparate objects in a collection when they all are alike in the actions carried out using them. There are [examples](https://github.com/kyleingraham/potcake#examples) as well if you'd like to see super-simple apps demonstrating the framework's features. There isn't much documentation in the code yet but the README covers what's available. I would love to one day duplicate Django's application concept where libraries specifically made for Django can ship templates, static files, and code that is easy to integrate in a Django project. Part of what's needed is there with collecting static files from multiple directories but there's still lots of ground to cover.
Jul 15 2023