From cb38145bf5f428468f1d9677bc68abb9729a954a Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Tue, 27 Feb 2024 17:51:09 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Doc=20and=20code=20tweaks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 45 +++++++++++++++++++++++++++++++++++++-------- src/config/file.rs | 6 +----- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6d3b4e52..cefa51b8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,35 @@ crates to provide extensible and easily configurable features. frequent changes. Production use is not recommended until version **0.1.0**. +# ⚡️ Quick start + +```rust +use pagetop::prelude::*; + +struct HelloWorld; + +impl PackageTrait for HelloWorld { + fn configure_service(&self, scfg: &mut service::web::ServiceConfig) { + scfg.route("/", service::web::get().to(hello_world)); + } +} + +async fn hello_world(request: service::HttpRequest) -> ResultPage { + Page::new(request) + .with_component(Html::with(html! { h1 { "Hello World!" } })) + .render() +} + +#[pagetop::main] +async fn main() -> std::io::Result<()> { + Application::prepare(&HelloWorld).run()?.await +} +``` + +This program features a `HelloWorld` package, providing a service that serves a greeting web page +accessible via `http://localhost:8088` under default settings. + + # 📂 Repository Structure This repository is organized into a workspace that includes several subprojects, each serving a @@ -35,6 +64,14 @@ distinct role within the PageTop ecosystem: and maintenance of dynamic, fast, and secure websites. It uses the following essential packages to provide standard CMS functionalities. +## Helpers + +* [pagetop-macros](https://github.com/manuelcillero/pagetop/tree/main/helpers/pagetop-macros): + A collection of procedural macros that enhance the development experience within PageTop. + +* [pagetop-build](https://github.com/manuelcillero/pagetop/tree/main/helpers/pagetop-build): + Simplifies the process of embedding resources directly into binary files for PageTop applications. + ## Packages * [pagetop-user](https://github.com/manuelcillero/pagetop/tree/main/packages/pagetop-user): @@ -56,14 +93,6 @@ distinct role within the PageTop ecosystem: * [pagetop-bulmix](https://github.com/manuelcillero/pagetop/tree/main/packages/pagetop-bulmix): Utilizes the *[Bulma](https://bulma.io/)* framework for sleek, responsive design elements. -## Helpers - -* [pagetop-macros](https://github.com/manuelcillero/pagetop/tree/main/helpers/pagetop-macros): - A collection of procedural macros that enhance the development experience within PageTop. - -* [pagetop-build](https://github.com/manuelcillero/pagetop/tree/main/helpers/pagetop-build): - Simplifies the process of embedding resources directly into binary files for PageTop applications. - # 📜 License diff --git a/src/config/file.rs b/src/config/file.rs index 6f760e36..00f0c34d 100644 --- a/src/config/file.rs +++ b/src/config/file.rs @@ -67,11 +67,7 @@ where fn collect(&self) -> Result> { // Coerce the file contents to a string. - let (uri, contents) = match self - .source - .resolve() - .map_err(ConfigError::Foreign) - { + let (uri, contents) = match self.source.resolve().map_err(ConfigError::Foreign) { Ok((uri, contents)) => (uri, contents), Err(error) => {