Implementing POST user
To create a user, we are going to use the new_user
and create_user
functions. The new_user()
function is relatively easy to implement; we just need to serve an HTML page with a form for a user to fill in.
Let's look at the steps:
- Implement the
new_user()
function insrc/routes/user.rs
:#[get("/users/new", format = "text/html")] pub async fn new_user() -> HtmlResponse { let mut html_string = String::from(USER_HTML_ PREFIX); html_string.push_str( r#"<form accept-charset="UTF-8" action="/ users" autocomplete="off" method="POST"> <div> <label for="username">Username:</label> &...