A Rust web framework

Overview

cargonauts - a Rust web framework

Join the chat at https://gitter.im/cargonauts-rs/cargonauts

Documentation

cargonauts is a Rust web framework intended for building maintainable, well-factored web apps.

This project is a work in progress. It has not been hardened or audited for security. Expect frequent breaking changes. Use at your own risk.

Core concepts

  • REST-first & resource oriented: cargonauts is designed for constructing applications as networks of related resources which support methods. It comes with a JSON API hypermedia API format.
  • Cleanly decoupled & well-factored: cargonauts provides many different building blocks for your application, with clear interfaces between them. Used correctly, it can help you keep your app from turning into a pile of spaghetti.
  • Async always: cargonauts is built on top of tokio; your application will use asynchronous IO out of the box.

License

Cargonauts is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Code of Conduct

This project is governed by the Code of Conduct, found in the root of this repository. The Code of Conduct has been adapted from the Contributor Covenant.

Comments
  • cargonauts needs CI

    cargonauts needs CI

    I've been manually confirming that the tests are green before committing, but I should really set up CI sooner or later to make sure I never miss a commit.

    opened by withoutboats 4
  • Lattice specialization could allow methods to be removed from macro

    Lattice specialization could allow methods to be removed from macro

    The current syntax of the routes! macro requires the author to specify every method each resource supports, e.g.:

    routes! {
         resource Photo => ["get", "index", "put"] { ... }
    }
    

    The user then additionally provides an impl of the trait associated with each method for Photo.

    This is redundant work, but its necessary for the macro to be expanded in a way which attaches each method for that resource (see the methods! macro in the current version of the source).

    With lattice specialization, we could instead provide a single entry point, specialized for all of the combinations of methods that could be supported. This would be a lot of boilerplate for cargonauts, but it would save much more boilerplate for cargonauts users. For example:

    struct<R: router::Router> Router<R> {
        // underlying method specific functions
        fn attach_get<T: Get>(&mut self) { ... }
        fn attach_index<T: Index>(&mut self) { ... }
    
        // specialized entry point method
        default fn attach_methods<T>(&mut self) {
            // base case is null - you have defined no methods for this resource
        }
        default fn attach_methods<T: Get>(&mut self) {
            self.attach_get::<T>();
        }
        default fn attach_methods<T: Index>(&mut self) {
            self.attach_index::<T>();
        }
        fn attach_methods<T: Get + Index>(&mut self) {
            self.attach_get::<T>();
            self.attach_index::<T>();
        }
    }
    

    This requires lattice specialization because the method traits do not form a specialization order between them.

    enhancement 
    opened by withoutboats 3
  • `0.2-release` doesn't compile with more recent nightly

    `0.2-release` doesn't compile with more recent nightly

    There's an issue with max() being implemented in both the standard library and in (a presumably older version of) petgraph that's causing an error when building the 0.2 version of cargonauts now. This is only an issue because this is the branch installed by default with the CLI tool so the getting started experience was a little rocky.

    Changing the autogenerated Cargo.toml file from branch = "0.2-release" to branch = "master" fixes it (so this should hopefully close whenever the next release is pinned in the CLI).

    opened by bovee 1
  • Print address the server is running on

    Print address the server is running on

    This PR is a one line change that prints out Running on 127.0.0.1:7878 or whatever address it is running on.

    When trying out cargonauts I was confused about which port it was running on, so I thought it might be useful to print it out.

    opened by johansigfrids 1
  • Representable

    Representable

    Opening a PR because this changes the Cargo.toml to pull serde from a fork & I'm not sure about deciding to commit to that (waiting to see how things shake out in the serde PR).

    This PR changes several things:

    1. Includes are now represented using a trait object, because the fork of serde used now supports that.
    2. Supports sparse fieldsets by defining a new "Represent" trait, which is a variant on "Serialize" that takes a field set as an additional argument. A derive macro for the Represent trait is forthcoming.
    3. Defines a new "Presenter" layer. This is a big change and larger orthogonal to the others (but for a while I wasn't sure it would be), and maybe it can be split out into its own commit. JsonApi is now just a "presenter" layer, which defines how responses are presented. Other people can define alternative "presenters" out of tree, and in the future I want to support at least a server-side rendered templated HTML "presenter" in tree, probably built on a variant of handlebars or moustache or whatever.
    opened by withoutboats 1
  • Add a Gitter chat badge to README.md

    Add a Gitter chat badge to README.md

    cargonauts-rs/cargonauts now has a Chat Room on Gitter

    @withoutboats has just created a chat room. You can visit it here: https://gitter.im/cargonauts-rs/cargonauts.

    This pull-request adds this badge to your README.md:

    Gitter

    If my aim is a little off, please let me know.

    Happy chatting.

    PS: Click here if you would prefer not to receive automatic pull-requests from Gitter in future.

    opened by gitter-badger 0
  • First draft front end for compass-rose.

    First draft front end for compass-rose.

    compass-rose is a replacement for the routes! macro, a compiler for the routes DSL based on LALRPOP. It will be more robust and permissive, have better error messages, and support multiple backends aside from generating routing code - such as swagger documentation.

    opened by withoutboats 0
  • Update docs about using the chrono crate

    Update docs about using the chrono crate

    On this page, https://cargonauts-rs.github.io/cargonauts/ping.html, the docs talk about using chrono and version 0.3.1. That version appears to have been yanked https://crates.io/crates/chrono/0.3.1. The current latest version if 0.4 which switches to using Utc vs UTC. (note the uppercase). Trying to build the example with chrono 0.4 results in ^^^ noUTCin the root.

    opened by ducks 0
  • Asset Pipeline

    Asset Pipeline

    I noticed on #7 that you mention being able to dynamically load templates and assets, and that got me wondering about how you imagine cargonauts users will handle assets.

    I recently released a crate for embedding entire directory trees in your binary, so kinda like include_str, but on steroids. Would something like that be useful for when people want to deploy their apps to production?

    On the dynamic reloading side of things, it sounds like you want something which can watch a directory, caching resources which you've served in the past, and reloading them when they are changed (presumably with notify). Have you started work on any of the asset pipeline stuff yet? I'd be keen to help out.

    opened by Michael-F-Bryan 1
  • A logo

    A logo

    I'm interested in helping with this project, but as a Rust noob, my code contributions might be minimal. I do have a modicum of skill with design, so I would like to contribute with a logo and some general design for the project.

    I've attached an idea for a logo, which is heavily influenced by the badges worn by astro/cosmo-nauts. I am not proposing this exact thing, I really just wanted to attach something to stimulate discussion.

    cargonauts-proposal

    opened by lukesutton 1
  • Integration tests are flakey on CI

    Integration tests are flakey on CI

    cargonauts has some integration tests that run the examples in the examples directory and make requests of them, to make sure the whole system is working at least kind of correctly.

    These have proven to be pretty flakey on CI, failing requests with ConnectionRefused a litle too often. I don't know why this is but would be great for this to get fixed somehow. Ideas:

    1. Figure out why this happens on CI (doesnt happen on my machine) and maybe there's a config on travis that could be changed to fix it.
    2. Maybe there's a small change to the tests that could fix the problem.
    3. If not, figure out another way to get the same end-to-end testing without actually performing a TCP connection.
    help wanted 
    opened by withoutboats 0
  • Add a CPU pool to environment.

    Add a CPU pool to environment.

    This adds two methods:

    • on_pool, which allows you to run a closure on the CPU pool.
    • sync_conn, which allows you to access a synchronous connection, managed by r2d2 (it is not possible to set up such a connection yet; more coming!).

    The CPU pool has 4 * the number of CPU threads. Someday this number will be configurable.

    opened by withoutboats 0
Owner
null
A (flash) message framework for actix-web. A port to Rust of Django's message framework.

actix-web-flash-messages Flash messages for actix-web Web applications sometimes need to show a one-time notification to the user - e.g. an error mess

Luca Palmieri 31 Dec 29, 2022
Hot reload static web server for deploying mutiple static web site with version control.

SPA-SERVER It is to provide a static web http server with cache and hot reload. 中文 README Feature Built with Hyper and Warp, fast and small! SSL with

null 7 Dec 18, 2022
Code template for a production Web Application using Axum: The AwesomeApp Blueprint for Professional Web Development.

AwesomeApp rust-web-app More info at: https://awesomeapp.dev/rust-web-app/ rust-web-app YouTube episodes: Episode 01 - Rust Web App - Course to Produc

null 45 Sep 6, 2023
A highly customizable, full scale web backend for web-rwkv, built on axum with websocket protocol.

web-rwkv-axum A axum web backend for web-rwkv, built on websocket. Supports BNF-constrained grammar, CFG sampling, etc., all streamed over network. St

Li Junyu 12 Sep 25, 2023
A Rust web framework

cargonauts - a Rust web framework Documentation cargonauts is a Rust web framework intended for building maintainable, well-factored web apps. This pr

null 179 Dec 25, 2022
A rust web framework with safety and speed in mind.

darpi A web api framework with speed and safety in mind. One of the big goals is to catch all errors at compile time, if possible. The framework uses

null 32 Apr 11, 2022
A web framework for Rust.

Rocket Rocket is an async web framework for Rust with a focus on usability, security, extensibility, and speed. #[macro_use] extern crate rocket; #[g

Sergio Benitez 19.4k Jan 4, 2023
Rust / Wasm framework for building client web apps

Yew Rust / Wasm client web app framework Documentation (stable) | Documentation (latest) | Examples | Changelog | Roadmap | 简体中文文档 | 繁體中文文檔 | ドキュメント A

Yew Stack 25.8k Jan 2, 2023
Thruster - An fast and intuitive rust web framework

A fast, middleware based, web framework written in Rust

null 913 Dec 27, 2022
A full-featured and easy-to-use web framework with the Rust programming language.

Poem Framework A program is like a poem, you cannot write a poem without writing it. --- Dijkstra A full-featured and easy-to-use web framework with t

Poem Web 2.2k Jan 6, 2023
Perseus is a blazingly fast frontend web development framework built in Rust with support for major rendering strategies

Perseus is a blazingly fast frontend web development framework built in Rust with support for major rendering strategies, reactivity without a virtual DOM, and extreme customizability

arctic_hen7 1.2k Jan 8, 2023
Seed is a Rust front-end framework for creating fast and reliable web apps with an Elm-like architecture.

Seed is a Rust front-end framework for creating fast and reliable web apps with an Elm-like architecture.

null 3.6k Jan 6, 2023
Experiments with Rust CRDTs using Tokio web application framework Axum.

crdt-genome Synopsis Experiments with Rust CRDTs using Tokio web application framework Axum. Background Exploring some ideas of Martin Kleppmann, part

dougfort 3 Mar 18, 2022
Implementation of the RealWorld backend API spec in Actix, Rust's powerful actor system and most fun web framework.

Actix codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API. ❗ (2021/05/13) This cod

Allen 475 Jan 2, 2023
Super Fast & High Performance minimalist web framework for rust

Super Fast & High Performance minimalist web framework for rust

null 6 Oct 12, 2022
A web framework for Rust programing language

kalgan A web framework for Rust programing language. Getting Started Create your project with cargo: cargo new project Add the dependency in Cargo.tom

Eduardo Casas 4 Jun 9, 2022
Demo of Rust and axum web framework

Demo of Rust and axum web framework Demonstration of: Rust: programming language that focuses on reliability and stability. axum: web framework that f

Joel Parker Henderson 115 Dec 29, 2022
A super-easy, composable, web server framework for warp speeds.

warp A super-easy, composable, web server framework for warp speeds. The fundamental building block of warp is the Filter: they can be combined and co

Sean McArthur 7.5k Jan 2, 2023
Axum web framework tutorial for beginners.

Axum Tutorial For Beginners Hello web developers! This tutorial will cover how to write simple web applications in rust with axum framework. If you ar

Eray Karatay 46 Jan 5, 2023