64 lines
1.2 KiB
Bash
Executable file
64 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
help() {
|
|
echo "Usage: gen_handler.sh <handler partial name> <handler route> <payload struct partial name>"
|
|
}
|
|
|
|
|
|
run() {
|
|
|
|
echo "cfg.service($1_ui_handler);"
|
|
echo "cfg.service($1_form_submission_handler);"
|
|
|
|
|
|
echo "
|
|
#[allow(clippy::too_many_arguments)]
|
|
#[get(\"$2\")]
|
|
#[tracing::instrument(name = \"login UI handler\", skip())]
|
|
async fn login_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
|
const LOGIN_PAGE: &str = include_str!(\"./owner_login.html\");
|
|
|
|
Ok(HttpResponse::Ok()
|
|
.insert_header(ContentType::html())
|
|
.body(LOGIN_PAGE))
|
|
}
|
|
|
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
|
struct $3Payload {
|
|
password: String,
|
|
}
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
#[post(\"$2\")]
|
|
#[tracing::instrument(
|
|
name = \"Login form submission handler\"
|
|
skip(id, req, payload, identity_cqrs_exec)
|
|
)]
|
|
async fn login_form_submission_handler(
|
|
identity_cqrs_exec: types::WebIdentityCqrsExec,
|
|
req: HttpRequest,
|
|
id: Identity,
|
|
payload: web::Form<$3Payload>,
|
|
) -> WebJsonRepsonse<impl Responder> {
|
|
let store = \"\";
|
|
|
|
Ok(HttpResponse::Ok().json(store))
|
|
}
|
|
"
|
|
}
|
|
|
|
|
|
|
|
if [ -z $1 ]
|
|
then
|
|
help
|
|
elif [ -z $2 ]
|
|
then
|
|
help
|
|
elif [ -z $3 ]
|
|
then
|
|
help
|
|
else
|
|
run $1 $2 $3 | wl-copy
|
|
run $1 $2 $3
|
|
fi
|