diff --git a/static/index.html b/static/index.html index a4a8fce..0a97362 100644 --- a/static/index.html +++ b/static/index.html @@ -1,5 +1,6 @@ +
+
Syntax, stdlib and types for PHP
- - val person_id = POST::get("person_id") ?: die - - match Person::find_by_id(person_id) - | Ok(person) - { - JSON::encode(person) - } - | Err(e) - { - JSON::encode(Obj {"error": e}) - } - -
- val person_id = POST::get("person_id") ?: die - - match Person::find_by_id(person_id) - | Ok(person) - { - JSON::encode(person) - } - | Err(e) - { - JSON::encode(Obj {"error": e}) - } -
+ + fun find_person(Str person_id) -> Result[Str] { + let person_id = try person_id.parse[Int]() + try Person::find_by_id(person_id) + } + + let id = POST::get("person_id") ?: die + let person = find_person(person_id: id) ?: die + + print( + <a href="/person/reports/{person.id}"> + Hello {person.name} + </div> + ) + +
+ fun find_person(Str person_id) -> Result[Str] { + let person_id = try person_id.parse[Int]() + try Person::find_by_id(person_id) + } + + let id = POST::get("person_id") ?: die + let person = find_person(person_id: id) ?: die + + print( + <a href="/person/reports/{person.id}"> + Hello {person.name} + </div> + ) +