Skip to content

Latest commit

 

History

History
 
 

cmd

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Webgo Sample

Server Sent Events

sse-demo

This picture shows the sample SSE implementation provided with this application. In the sample app, the server is sending timestamp every second, to all the clients.

Important: SSE is a live connection between server & client. So a short WriteTimeout duration in webgo.Config will keep dropping the connection. If you have any middleware which is setting deadlines or timeouts on the request.Context, will also effect these connections.

How to run

If you have Go installed on your computer, open the terminal and:

$ cd $GOPATH/src
$ mkdir -p github.com/bnkamalesh
$ cd github.com/bnkamalesh
$ git clone https://github.com/bnkamalesh/webgo.git
$ cd webgo
$ go run cmd/*.go

Info 2020/06/03 12:55:26 HTTP server, listening on :8080

Or if you have Docker, open the terminal and:

$ git clone https://github.com/bnkamalesh/webgo.git
$ cd webgo
$ docker run \
-p 8080:8080 \
-v ${PWD}:/go/src/github.com/bnkamalesh/webgo/ \
-w /go/src/github.com/bnkamalesh/webgo/cmd \
--rm -ti golang:latest go run *.go

Info 2020/06/03 12:55:26 HTTP server, listening on :8080

You can try the following API calls with the sample app. It also uses all the features provided by webgo

  1. https://localhost:8080/
    • Loads an HTML page
  2. https://localhost:8080/matchall/
  3. https://localhost:8080/api/<param>
  4. https://localhost:8080/error-setter
    • Route which sets an error and sets response status 500
  5. https://localhost:8080/v5.4/api/<param>