Skip to content

Commit

Permalink
adds doc
Browse files Browse the repository at this point in the history
  • Loading branch information
rvflash committed Mar 4, 2019
1 parent f7dce7e commit 750d697
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.idea
examples/ack/ack
examples/server/server
examples/client/client
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# TCP

[![GoDoc](https://godoc.org/github.com/rvflash/tcp?status.svg)](https://godoc.org/github.com/rvflash/tcp)
[![Build Status](https://img.shields.io/travis/rvflash/tcp.svg)](https://travis-ci.org/rvflash/tcp)
[![Code Coverage](https://img.shields.io/codecov/c/github/rvflash/tcp.svg)](http://codecov.io/github/rvflash/tcp?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/rvflash/tcp)](https://goreportcard.com/report/github.com/rvflash/tcp)

TCP provides interfaces to create a TCP server.


Expand Down Expand Up @@ -29,15 +34,28 @@ Assuming the following code that runs a server on port 9090:
```go
package main

import "github.com/rvflash/tcp"
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.Conn) {
r.ACK(func(c *tcp.Context) {
// new message received
b := c.RawData()
// ...
// gets the request body
buf, err := c.ReadAll()
if err != nil {
c.Error(err)
}
// writes something as response
c.String(string(buf))
})
_ = r.Run(":9090") // listen and serve on 0.0.0.0:9090
err := r.Run(":9090") // listen and serve on 0.0.0.0:9090
if err != nil {
log.Fatalf("listen: %s", err)
}
}
```
Binary file added example/client/client
Binary file not shown.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package tcp_test

import "testing"

func TestNew(t *testing.T) {

}

func TestDefault(t *testing.T) {

}

0 comments on commit 750d697

Please sign in to comment.