01-hello-world

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: 1 Imported by: 0

README

Hello World Example

Tags: Models

Description

Simple service serving a message to the world.

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/01-hello-world
go run .

Things to try out

Access API through HTTP
  • Open the browser and go to:
    http://localhost:8080/api/example/model
    
Access API through WebSocket
  • Open Chrome and go to resgate.io - resource viewer.
  • Type in the resource ID below, and click View:
    example.model
    

    Note

    Chrome allows websites to connect to localhost, while other browsers may give a security error.

Real time update on static resource
  • Stop the project, and change the "Hello, World!" message in main.go.
  • Restart the project and observe how the message is updated in the viewer (see above).
Get resource with ResClient
  • In the resgate.io - resource viewer, open the DevTools console (Ctrl+Shift+J).
  • Type the following command, and press Enter:
    client.get("example.model").then(m => console.log(m.message));
    

    Note

    The resource viewer app stores the ResClient instance in the global client variable, for easy access.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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