From 4bd4ba3c689aa6adc0c6b33ed4c573e01a6c55fd Mon Sep 17 00:00:00 2001 From: Vitalie Date: Wed, 1 Apr 2020 16:52:36 +0300 Subject: [PATCH 1/5] AppServer - Update --- readme.md | 78 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 15 deletions(-) diff --git a/readme.md b/readme.md index d1d19f2..f49476b 100644 --- a/readme.md +++ b/readme.md @@ -1,23 +1,71 @@ # ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) AppServer -[![](https://img.shields.io/github/v/release/codemodify/systemkit-appserver?style=flat-square)](https://github.com/codemodify/systemkit-appserver/releases/latest) -![](https://img.shields.io/github/languages/code-size/codemodify/systemkit-appserver?style=flat-square) -![](https://img.shields.io/github/last-commit/codemodify/systemkit-appserver?style=flat-square) -[![](https://img.shields.io/badge/license-0--license-brightgreen?style=flat-square)](https://github.com/codemodify/TheFreeLicense) +[![GoDoc](https://godoc.org/github.com/codemodify/systemkit-logging?status.svg)](https://godoc.org/github.com/codemodify/systemkit-appsever) +[![0-License](https://img.shields.io/badge/license-0--license-brightgreen)](https://github.com/codemodify/TheFreeLicense) +[![Go Report Card](https://goreportcard.com/badge/github.com/codemodify/systemkit-appsever)](https://goreportcard.com/report/github.com/codemodify/systemkit-appsever) +[![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) +![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) -![](https://img.shields.io/github/workflow/status/codemodify/systemkit-appserver/qa?style=flat-square) -![](https://img.shields.io/github/issues/codemodify/systemkit-appserver?style=flat-square) -[![](https://goreportcard.com/badge/github.com/codemodify/systemkit-appserver?style=flat-square)](https://goreportcard.com/report/github.com/codemodify/systemkit-appserver) +#### Robust AppServer for Go. -[![](https://img.shields.io/badge/godoc-reference-brightgreen?style=flat-square)](https://godoc.org/github.com/codemodify/systemkit-appserver) -![](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square) -![](https://img.shields.io/gitter/room/codemodify/systemkit-appserver?style=flat-square) -![](https://img.shields.io/github/contributors/codemodify/systemkit-appserver?style=flat-square) -![](https://img.shields.io/github/stars/codemodify/systemkit-appserver?style=flat-square) -![](https://img.shields.io/github/watchers/codemodify/systemkit-appserver?style=flat-square) -![](https://img.shields.io/github/forks/codemodify/systemkit-appserver?style=flat-square) +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Install +```go +go get github.com/codemodify/systemkit-events +``` -### The Missing Application Server in Go +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) API + +  |   +--- | --- +--- | --- +--- | --- +--- | --- +--- | --- + + +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Usage +```go +func main() { + logging.Init(logging.NewConsoleLogger()) + + const port = 9999 + + fmt.Println(fmt.Sprintf("curl localhost:%d/SayHello", port)) + fmt.Println(fmt.Sprintf("curl localhost:%d/EchoBack -X POST -d 'should-send-back-the-same'", port)) + fmt.Println(fmt.Sprintf("curl localhost:%d/MyRestEndopint -H \"Content-Type: application/json\" -X POST -d '{\"Field1\":\"val1\", \"Field2\": 0, \"Field3\": 1.0, \"Field4\": true}'", port)) + fmt.Println("ALSO: open the 'sample.html' to see data streaming") + + jm.NewMixedServer([]jm.IServer{ + jm.NewHTTPServer([]jm.HTTPHandler{ + jm.HTTPHandler{ + Route: "/SayHello", + Verb: "GET", + Handler: sayHelloRequestHandler, + }, + jm.HTTPHandler{ + Route: "/EchoBack", + Verb: "POST", + Handler: echoBackRequestHandler, + }, + }), + jm.NewJSONServer([]jm.JSONHandler{ + jm.JSONHandler{ + Route: "/MyRestEndopint", + Template: &IncomingJson{}, + Handler: jsonRequestHandler, + }, + }), + jm.NewWebSocketsServer([]jm.WebSocketsHandler{ + jm.WebSocketsHandler{ + Route: "/StreamTelemetry", + Handler: streamTelemetryRequestHandler, + }, + }), + }).Run(fmt.Sprintf(":%d", port), true) +} +``` + +>### `The Missing Application Server in Go` - If http://tomcat.apache.org provides Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies - `AppServer` provides an alternative way to write in Go From 3d2db396754670913703b5e5871a9a65bc9a3798 Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sat, 4 Apr 2020 15:00:42 +0300 Subject: [PATCH 2/5] Update readme.md --- readme.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/readme.md b/readme.md index f49476b..b653734 100644 --- a/readme.md +++ b/readme.md @@ -13,6 +13,7 @@ go get github.com/codemodify/systemkit-events ``` +<<<<<<< Updated upstream # ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) API   |   @@ -66,6 +67,34 @@ func main() { ``` >### `The Missing Application Server in Go` +======= +### The Missing Application Server in Go +#### Supported: Linux, Raspberry Pi, FreeBSD, Mac OS, Windows, Solaris + +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Install +```go +go get github.com/codemodify/systemkit-appserver +``` +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) API + +  |   +--- | --- +NewHTTPServer(`handlers`) | --- +NewMixedServer(`servers`) | --- +NewJSONServer(`handlers`) | --- +NewSSHTunnelServer(`sshServerConfig`, `server`) | --- +NewWebSocketsServer(`handlers`) | --- +Run(`ipPort`, `enableCORS`) | --- +PrepareRoutes(`router`) | --- +RunOnExistingListenerAndRouter(`listener`, `router`, `enableCORS`) | --- +Write(`data`) (`int`, err`or) | --- +runSSH(`connection` ) | --- +setupCommunication(`ws`, han`dler) | --- +SendToAllPeers(`data`) | --- +addPeer(`peer`) | --- +removePeer(`peer`) | --- + +>>>>>>> Stashed changes - If http://tomcat.apache.org provides Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies - `AppServer` provides an alternative way to write in Go @@ -74,3 +103,52 @@ func main() { - Web Apps Frameworks - analogy for NodeJS + Express - For sample servers see `samples/sample.go` and `samples/sample.html` + +# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Usage +```go +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "sync" + "time" + + logging "github.com/codemodify/systemkit-logging" + + jm "github.com/codemodify/systemkit-appserver" +) + +func main() { + + jm.NewMixedServer([]jm.IServer{ + jm.NewHTTPServer([]jm.HTTPHandler{ + jm.HTTPHandler{ + Route: "/SayHello", + Verb: "GET", + Handler: sayHelloRequestHandler, + }, + jm.HTTPHandler{ + Route: "/EchoBack", + Verb: "POST", + Handler: echoBackRequestHandler, + }, + }), + jm.NewJSONServer([]jm.JSONHandler{ + jm.JSONHandler{ + Route: "/MyRestEndopint", + Template: &IncomingJson{}, + Handler: jsonRequestHandler, + }, + }), + jm.NewWebSocketsServer([]jm.WebSocketsHandler{ + jm.WebSocketsHandler{ + Route: "/StreamTelemetry", + Handler: streamTelemetryRequestHandler, + }, + }), + }).Run(fmt.Sprintf(":%d", port), true) +} +``` \ No newline at end of file From 1378e47356a868d1d6da4e9ace62126fe0e1c2c7 Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sat, 4 Apr 2020 15:13:46 +0300 Subject: [PATCH 3/5] Update readme.md --- readme.md | 64 ------------------------------------------------------- 1 file changed, 64 deletions(-) diff --git a/readme.md b/readme.md index b653734..1bbb869 100644 --- a/readme.md +++ b/readme.md @@ -5,69 +5,6 @@ [![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) ![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) -#### Robust AppServer for Go. - - -# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Install -```go -go get github.com/codemodify/systemkit-events -``` - -<<<<<<< Updated upstream -# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) API - -  |   ---- | --- ---- | --- ---- | --- ---- | --- ---- | --- - - -# ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Usage -```go -func main() { - logging.Init(logging.NewConsoleLogger()) - - const port = 9999 - - fmt.Println(fmt.Sprintf("curl localhost:%d/SayHello", port)) - fmt.Println(fmt.Sprintf("curl localhost:%d/EchoBack -X POST -d 'should-send-back-the-same'", port)) - fmt.Println(fmt.Sprintf("curl localhost:%d/MyRestEndopint -H \"Content-Type: application/json\" -X POST -d '{\"Field1\":\"val1\", \"Field2\": 0, \"Field3\": 1.0, \"Field4\": true}'", port)) - fmt.Println("ALSO: open the 'sample.html' to see data streaming") - - jm.NewMixedServer([]jm.IServer{ - jm.NewHTTPServer([]jm.HTTPHandler{ - jm.HTTPHandler{ - Route: "/SayHello", - Verb: "GET", - Handler: sayHelloRequestHandler, - }, - jm.HTTPHandler{ - Route: "/EchoBack", - Verb: "POST", - Handler: echoBackRequestHandler, - }, - }), - jm.NewJSONServer([]jm.JSONHandler{ - jm.JSONHandler{ - Route: "/MyRestEndopint", - Template: &IncomingJson{}, - Handler: jsonRequestHandler, - }, - }), - jm.NewWebSocketsServer([]jm.WebSocketsHandler{ - jm.WebSocketsHandler{ - Route: "/StreamTelemetry", - Handler: streamTelemetryRequestHandler, - }, - }), - }).Run(fmt.Sprintf(":%d", port), true) -} -``` - ->### `The Missing Application Server in Go` -======= ### The Missing Application Server in Go #### Supported: Linux, Raspberry Pi, FreeBSD, Mac OS, Windows, Solaris @@ -94,7 +31,6 @@ SendToAllPeers(`data`) | --- addPeer(`peer`) | --- removePeer(`peer`) | --- ->>>>>>> Stashed changes - If http://tomcat.apache.org provides Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies - `AppServer` provides an alternative way to write in Go From 15c148428beb5fe5573945dbd229955d4a6f0f2c Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sat, 4 Apr 2020 15:15:24 +0300 Subject: [PATCH 4/5] Update readme.md --- readme.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 1bbb869..4b3afe7 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,21 @@ # ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) AppServer -[![GoDoc](https://godoc.org/github.com/codemodify/systemkit-logging?status.svg)](https://godoc.org/github.com/codemodify/systemkit-appsever) -[![0-License](https://img.shields.io/badge/license-0--license-brightgreen)](https://github.com/codemodify/TheFreeLicense) -[![Go Report Card](https://goreportcard.com/badge/github.com/codemodify/systemkit-appsever)](https://goreportcard.com/report/github.com/codemodify/systemkit-appsever) -[![Test Status](https://github.com/danawoodman/systemservice/workflows/Test/badge.svg)](https://github.com/danawoodman/systemservice/actions) -![code size](https://img.shields.io/github/languages/code-size/codemodify/SystemKit?style=flat-square) +[![](https://img.shields.io/github/v/release/codemodify/systemkit-appserver?style=flat-square)](https://github.com/codemodify/systemkit-appserver/releases/latest) +![](https://img.shields.io/github/languages/code-size/codemodify/systemkit-appserver?style=flat-square) +![](https://img.shields.io/github/last-commit/codemodify/systemkit-appserver?style=flat-square) +[![](https://img.shields.io/badge/license-0--license-brightgreen?style=flat-square)](https://github.com/codemodify/TheFreeLicense) + +![](https://img.shields.io/github/workflow/status/codemodify/systemkit-appserver/qa?style=flat-square) +![](https://img.shields.io/github/issues/codemodify/systemkit-appserver?style=flat-square) +[![](https://goreportcard.com/badge/github.com/codemodify/systemkit-appserver?style=flat-square)](https://goreportcard.com/report/github.com/codemodify/systemkit-appserver) + +[![](https://img.shields.io/badge/godoc-reference-brightgreen?style=flat-square)](https://godoc.org/github.com/codemodify/systemkit-appserver) +![](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square) +![](https://img.shields.io/gitter/room/codemodify/systemkit-appserver?style=flat-square) + +![](https://img.shields.io/github/contributors/codemodify/systemkit-appserver?style=flat-square) +![](https://img.shields.io/github/stars/codemodify/systemkit-appserver?style=flat-square) +![](https://img.shields.io/github/watchers/codemodify/systemkit-appserver?style=flat-square) +![](https://img.shields.io/github/forks/codemodify/systemkit-appserver?style=flat-square) ### The Missing Application Server in Go #### Supported: Linux, Raspberry Pi, FreeBSD, Mac OS, Windows, Solaris From 783293e79283f8d6db1779e40eb114a534a02513 Mon Sep 17 00:00:00 2001 From: Vitalie Date: Sat, 4 Apr 2020 15:20:12 +0300 Subject: [PATCH 5/5] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 4b3afe7..f42ca90 100644 --- a/readme.md +++ b/readme.md @@ -17,7 +17,7 @@ ![](https://img.shields.io/github/watchers/codemodify/systemkit-appserver?style=flat-square) ![](https://img.shields.io/github/forks/codemodify/systemkit-appserver?style=flat-square) -### The Missing Application Server in Go +#### The Missing Application Server in Go #### Supported: Linux, Raspberry Pi, FreeBSD, Mac OS, Windows, Solaris # ![](https://fonts.gstatic.com/s/i/materialicons/bookmarks/v4/24px.svg) Install