diff options
author | Yorhel <git@yorhel.nl> | 2020-01-05 12:47:04 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-01-05 12:52:12 +0100 |
commit | d1d981efa5b0910260cbd1c226e3ab683c8304ae (patch) | |
tree | 8704fd96dc8e5820dae8017e5bfaf882ed80980f /lib/VNWeb/Staff | |
parent | 0efea750ac26629f48fb50a9cdc9d71bd08257b7 (diff) |
refactor: Combine json_api() & elm_form() + generate Elm function to msg API endpoint
The new elm_api() function now creates an API endpoint (like json_api())
and generates a corresponding Elm module to interact with that API (like
elm_form()). The API endpoint URL is now derived from the name of the
Elm module, so there's no need to think of a separate URL and less prone
to making typos when using that URL from Elm.
Reduces the boilerplace a bit as well.
Diffstat (limited to 'lib/VNWeb/Staff')
-rw-r--r-- | lib/VNWeb/Staff/Edit.pm | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/VNWeb/Staff/Edit.pm b/lib/VNWeb/Staff/Edit.pm index 2feb52c1..deb5e7fc 100644 --- a/lib/VNWeb/Staff/Edit.pm +++ b/lib/VNWeb/Staff/Edit.pm @@ -31,8 +31,6 @@ my $FORM_OUT = form_compile out => $FORM; my $FORM_IN = form_compile in => $FORM; my $FORM_CMP = form_compile cmp => $FORM; -elm_form StaffEdit => $FORM_OUT, $FORM_IN; - TUWF::get qr{/$RE{srev}/edit} => sub { my $e = db_entry s => tuwf->capture('id'), tuwf->capture('rev') or return tuwf->resNotFound; @@ -65,7 +63,7 @@ TUWF::get qr{/s/new}, sub { }; -json_api qr{/s/edit\.json}, $FORM_IN, sub { +elm_api StaffEdit => $FORM_OUT, $FORM_IN, sub { my $data = shift; my $new = !$data->{id}; my $e = $new ? { id => 0 } : db_entry s => $data->{id} or return tuwf->resNotFound; |