Skip to content

Add Features for Easy Web App Creation#5

Merged
kyleingraham merged 18 commits intotrunkfrom
add-web-app-package
Jul 14, 2023
Merged

Add Features for Easy Web App Creation#5
kyleingraham merged 18 commits intotrunkfrom
add-web-app-package

Conversation

@kyleingraham
Copy link
Copy Markdown
Owner

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:

  • Django-style routing
  • Static file serving (with collection of files from multiple directories)
  • Django-style URL reversing
  • Middleware
  • Settings management

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 toPath functions 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. Use Variant instead of emplacing and cast for easier-to-use code.

Rehash Router associative arrays for performance.

Add static file handling via two approaches:

  • Single-directory approach where all files are stored in a single directory in
    development and production.
  • Collecting approach where static files are merged into one directory and served from a single routh path.

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.

    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.
@kyleingraham kyleingraham self-assigned this Jul 14, 2023
@kyleingraham kyleingraham merged commit 7a729d8 into trunk Jul 14, 2023
@kyleingraham kyleingraham deleted the add-web-app-package branch July 27, 2023 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant