cmd

command
v7.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 12 Imported by: 0

README

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/cmd
$ go run *.go

Info 2023/02/05 08:51:26 HTTP server, listening on :8080
Info 2023/02/05 08:51:26 HTTPS server, listening on :9595

Or if you have Docker, open the terminal and:

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

Info 2023/02/05 08:51:26 HTTP server, listening on :8080
Info 2023/02/05 08:51:26 HTTPS server, listening on :9595

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

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

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