JSON-RPC Client & Server
This page uses a Hashtag JSON-RPC Form to provide a client for a Hashtag Worker with multiple Services.
The form is styled using Bootstrap 3 default theme classes.
JavaScript is used to create an alert for received messages after requests are processed.
Processed this Hashtag Markup:
<# start json-rpc form using /json-rpc/server;
set form.class to "form-horizontal";
#>
<div class="form-group">
<label for="message" class="col-sm-3 control-label">Message</label>
<div class="col-sm-6">
<input type="text" <# message #> class="form-control">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<input type="button" <# Echo button #> class="btn btn-primary">
<input type="button" <# Ping button #> class="btn btn-primary">
</div>
</div>
<# start echo result #>
alert(result.message);
<# end echo result #>
<# start ping result #>
alert(result.message);
<# end ping result #>
<# end form #>
Hashtag Markup for Service Worker:
/json-rpc/server
<# start json-rpc worker; #>
<# start echo #>
<# set result.message to "<# params.message #>"; #>
<# end echo #>
<# start ping #>
<# set result.message to "pong"; #>
<# end ping #>
<# end json-rpc worker #>