02-edit-text

command
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2021 License: MIT Imports: 3 Imported by: 0

README

Edit Text Example

Tags: Models, Call methods, Client subscriptions

Description

A simple text field that can be edited by multiple clients simultaneously.

Prerequisite

  • Download and install Go
  • Install NATS Server and Resgate (done with 3 docker commands).

Install and run

git clone https://github.com/jirenius/go-res
cd go-res/examples/02-edit-text
go run .

Open the client

http://localhost:8082

Things to try out

Realtime updates
  • Open the client in two separate tabs.
  • Edit the message in one tab, and observe realtime updates in both.
System reset
  • Stop the service.
  • Edit the default text ("Hello, Go World!") in main.go.
  • Restart the service to observe resetting of the message in all clients.

API

Request Resource Description
get text.shared Simple model.
call text.shared.set Sets the model's message property.

REST API

Resources can be retrieved using ordinary HTTP GET requests, and methods can be called using HTTP POST requests.

Get model
GET http://localhost:8080/api/text/shared
Update model
POST http://localhost:8080/api/text/shared/set

Body

{ "message": "Updated through HTTP" }

Documentation

Overview

This is an example of a simple text field that can be edited by multiple clients. * It exposes a single resource: "text.shared". * It allows setting the resource's Message property through the "set" method. * It resets the model on server restart. * It serves a web client at http://localhost:8082

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL