Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,32 @@
![](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
```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`) | ---


- 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
Expand All @@ -26,3 +51,52 @@
- 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)
}
```