Add Features for Easy Web App Creation#5
Merged
kyleingraham merged 18 commits intotrunkfrom Jul 14, 2023
Merged
Conversation
Revamp WebApp 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. That prevents storing template
instantiations in a collection.
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.
Add the ability to obtain a route path by supplying a
pre-registered name and path arguments (reversing). The reversing
function makes use of a new reference to the initialized app at
runtime.
Add `toURL` functions for converting path arguments to their string
representations in paths.
Return a common exception from path converters to aid signaling
when a reversed path cannot be created.
Use `Variant` instead of emplacing and casts for easier-to-use
code.
Rehash `Router` associative arrays for performance.
Add static file handling via two approaches:
- Per-directory approach where each directory must be given a
unique route path.
- Collecting approach where static files are merged into one
directory and served from a single routh path.
Add method for building static paths in templates when using the
collecting approach.
Memoize staticPath to eliminate a 15% drop in performance it
previously added.
Add tests for static file serving.
Switch to module-level safe in some areas.
Add WebApp.addRoutes for adding all routes at once using a collection.
Make a trailing '/' optional when calling a route if the route's
path was specified with a trailing '/'.
Streamline static file serving for the single directory case. The
developer can configure serving via the settings object and all
static serving for all cases is now done via `serveStaticFiles`.
Update the readme to introduce all framework features.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restructure Potcake for easy web app creation. Web apps can be created through two new objects. WebApp and WebAppSettings. Through them we provide the following features:
Details:
Revamp URL dispatching 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. 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.
Add the ability to obtain a route path by supplying a pre-registered name and path arguments (reversing). The reversing function makes use of a new reference to the initialize app at runtime.
Add
toPathfunctions to path converters for converting path arguments to their string representations in paths. Return a common exception from path converters to aid signaling when a reversed path cannot be created. UseVariantinstead of emplacing and cast for easier-to-use code.Rehash
Routerassociative arrays for performance.Add static file handling via two approaches:
development and production.
Add staticPath method for building static paths in templates.
Add WebApp.addRoutes for adding all routes at once using a collection. Make a trailing '/' optional when calling a route if the route's path was specified with a trailing '/'
Streamline static file serving for the single directory case. The developer can configure serving via the settings object and all static serving for all cases is now done via
serveStaticFiles.Wrap all modules in @safe.