Skip to content

Commit

Permalink
adds start sample
Browse files Browse the repository at this point in the history
  • Loading branch information
rvflash committed Mar 4, 2019
1 parent be8e46b commit 36e2190
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
example/server/server
example/client/client
example/server/server
example/start/start
26 changes: 26 additions & 0 deletions example/start/start.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"log"

"github.com/rvflash/tcp"
)

func main() {
// creates a server with a logger and a recover on panic as middlewares.
r := tcp.Default()
r.ACK(func(c *tcp.Context) {
// new message received
// gets the request body
buf, err := c.ReadAll()
if err != nil {
c.Error(err)
}
// writes something as response
c.String(string(buf))
})
err := r.Run(":9090") // listen and serve on 0.0.0.0:9090
if err != nil {
log.Fatalf("listen: %s", err)
}
}

0 comments on commit 36e2190

Please sign in to comment.