Call For Example Web Projects
yoshuawuyts opened this issue · 9 comments
As part of the Net::Web WG we want to help people find their way around Web
programming in Rust (#37). One part of this story will be by sending out surveys
(#27, #40). But another thing we want to do is create a collection of examples
for common tasks in web programming.
We think that gathering a collection of documented example projects can help
us with a few things:
- Having a collection of example programs for common tasks is a helpful resource
for people that are new to web programming in Rust. - Inform which parts of the web story need to be improved.
- Serve as a useful reference for the upcoming Web Book.
What does an example program look like?
An example program should have the following things:
- A dedicated (GitHub) repository.
- A description in the README of the task it solves, and notable architecture
decisions. - A list of things that were tricky to figure out, or wish you could be
improved. - A link back from the project to this issue so people can explore other
projects.
And that's about it I think. I don't think we'd need to have many other
restrictions in place, as our purpose is to explore the different ways that
people solve web-related tasks in Rust.
What kind of examples are you looking for?
The goal is to have small examples that generally cover a single task. Examples
would include:
- Forward incoming connections to other servers using Tokio.
- Create an API around a full-text search engine to search in documents.
- Perform user authentication using PostgreSQL and cookies.
But these are just some example. We'd love to gather more! So if you have some
good ideas go ahead and comment below!
Where should we link these examples from?
Let's link them from this issue for now, but if we get enough examples we should
probably make a dedicated repo / link it from other web resources. But I propose
we do those things as they're rolled out, and instead place an initial focus on
creating content.
How is this different from the Rust Cookbook?
The Rust Cookbook is a resource that helps show how to perform a variety
of tasks in a wide range of domains using code snippets.
The goal of the example projects is to show off how to do common tasks in the
web domain using complete projects.
How can I get involved?
We'd love to have people both contribute ideas for common web tasks, and
implementations of projects!
If you have ideas that would be worth exploring, please comment in this thread.
Similarly, if you've implemented a task, feel free to link to it from this too.
Please include a description of the task your project solves, and any notable
architecture decision.
Hope this all makes sense. We're happy answer any questions people have, and
update this post to help clarify things.
Happy hacking!
Hi
I don't know if this is what you're looking for. I've been working on a presentation manager for reveal.js. I wrote about it here: https://medium.com/@mattdark/presentation-manager-written-in-rustlang-f36b73bb8dd2 and the repository is here: https://github.com/mattdark/presentation-manager-rs
I will update the README on weekend
Hi,
I have my own “open ID” interpretation available here : https://gitlab.com/Vrixyz/oauth-server.
The Readme has some details, I would be happy to answer questions about it, and continue (slowly) its development.
Be warned: it’s highly unpolished, WIP and NOT production ready.
I have been working on a blog in Rust and Rocket, the repo is at https://github.com/vishusandy/blogr
I have the app running at https://vishus.net which also contains a few tutorials/guides on web development and hosting a when app in Rust
https://vishus.net/content/tutorials
Ohhh, the contributions so far are really useful! If I could be so free, a thing that would be very helpful would be to hear more about the process. What was hard to do? What was easy to do? The more we know about what you ran into, the more it'll help us.
I've spent the afternoon implementing a small program for signup / login using Argon2 + Hyper. I figured it might be useful to share:
Project: secure signup / login
Design
I had the idea of building a quick login / signup API using two endpoints: /login
and /signup
. To be compatible with vanilla HTML, all data is taken from querystrings. To reduce the amount of implementation surface usgin Arc<Mutex<HashMap>>
as the database should be enough.
To make it as realistic as possible we should use the argon2
hash algorithm which can also defend from GPU accelerated attacks. And the program should run asynchronously over cpu_num
threads, with a friendly CLI frontend.
Crates Used
- structopt - CLI library
- rust-argon2 - for password hashing
- warp - HTTP framework
- rand - to fill random bytes for the password salt
Notes
- Using an
Arc<Mutex<HashMap>>
is a pretty great pattern to emulate any more difficult databases. Maybe we should make that a crate? Memdb? Testdb? Something like that. - I'm not sure how to handle errors in Warp yet. We probably need to specify a return type to handle it correctly. The errors weren't very helpful here, but that's probably because of the heavy use of generics in return types.
- Similarly I don't know how to return a filter from a function. That took a while to figure out, and eventually had to abandon it.
- Found out that Argon2 stores the salt in the hash itself, so there's only one value that needs to be stored. That's really nice!
- We should have a standard logger thing for HTTP info. Couldn't get the built-in warp logger to work (although I didn't spend too much time on figuring out how to make it work).
Thanks for he example of feedback, I started an issue on my project to attempt to help you : https://gitlab.com/Vrixyz/oauth-server/issues/6
As project might be numerous here, and discussion difficult to follow, If you have specific questions on my project, ask them on that issue, and for anything more generic, this thread will be the place.
I spent some time last year looking at ways to structure a web app in Rust, independently of specific web frameworks. The result is here. Unfortunately I haven't found a lot of time this year to keep it up to date, but would like to.
Create an API around a full-text search engine to search in documents
This piqued my interest. I don't have much practical experience with web development or Rust, but I thought I would contribute something and learn along the way. You can find my (very work-in-progress) implementation here. So far I've created a basic frontend and mocked out a REST query on the server-side. I'm currently using rocket
on the server, and I plan on using tantivy
for doing the indexing / queries.
I plan on indexing a subset of Project Gutenberg since it's in the public domain and is a moderately-sized corpus.
I wanted to try out warp before possible switching to it in a larger project, so I wrote https://github.com/kaj/warp-diesel-ructe-sample .
This project gives each handler access to a Session
object as well as any arguments from the URL parsing, containing a handle to a diesel database pool and a user (if logged in). It also uses ructe for server-side creation of user-facing html pages. Please see project readme for further details.
I wanted to better understand tokio and it's surrounding crates so I implemented a client for the Beanstalkd protocol.
Project: tokio-beanstalkd
Repository: https://github.com/bIgBV/tokio-beanstalkd
Design
The library is pretty simple in that is uses tokio-codec and implements the Encoder
and Decoder
traits for a simple codec. The public API is just methods provided by the protocol and internally these methods send
a request on the Sink
from the codec and read a single response from the Stream
and return it back to the caller.
It's still a work in progress, but I'm trying to make a simple to use and easy to understand API to interact with the work queue. The crate is at a state where most operations around jobs are implemented. I'm working on the rest slowly.
Crates Used
Notes
- Initially looked at tokio-proto but was deprecated
- Looked at tokio-codec which proved to be really good to work with.
- Took a long time to really get the mental model of working with tokio
- There was a lot of things to learn before I was productive.
- Felt that examples in the crates' documentation was very sparse. Especially around combinators.
- Finding examples was very difficult. Job Gjenset's tutorial series was extremely helpful.
- Using tokio-codec was extremely ergonomic once I was able to understand how everything fit together.
- Understanding how the combinators work took some time and getting used to.
- Error messages could be confusing at times. Especially when the wrong combinator was used.