Skip to content

Commit acee5e7

Browse files
author
XieBiao
committed
Write up readme
1 parent 10b5976 commit acee5e7

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

README.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,55 @@
1-
# go-db-proxy-api
2-
An efficient API is used to connect the database which is in private/intranet network.
1+
Database Proxy
2+
==============
3+
4+
A simple API is used to connect the database which is in private/intranet network.
5+
6+
## Usage
7+
8+
1. Install
9+
10+
```Shell
11+
//cd your-root-folder-of-project
12+
//Create the file glide.yaml if not exist
13+
//touch glide.yaml
14+
glide get github.com/hhxsv5/go-db-proxy-api#~1.0.0
15+
```
16+
17+
2. Config
18+
- config of database: config/db.toml
19+
- config of http server: config/http.toml
20+
21+
22+
3. Run
23+
24+
```Go
25+
var handlers = map[string]func(w http.ResponseWriter, r *http.Request){}
26+
handlers["/"] = func(w http.ResponseWriter, r *http.Request) {
27+
//rand.Seed(time.Now().UnixNano())
28+
//cellphone := "1878020" + strconv.Itoa(int(1000+rand.Int31n(9999-1000)))
29+
//mydefault.CreateUser(cellphone)
30+
31+
users := mydefault.GetUsersByIds([]uint64{})
32+
33+
var (
34+
rsp string
35+
it time.Time
36+
mt time.Time
37+
)
38+
39+
for i, u := range users {
40+
it = time.Unix(u.InsertTime, 0)
41+
mt = time.Unix(u.ModifyTime, 0)
42+
rsp += fmt.Sprintf("%d: %d, %s, %s, %s\n", i, u.Id, u.Cellphone, it.Format(time.RFC3339), mt.Format("2006-01-02 15:04:05"))
43+
}
44+
45+
io.WriteString(w, rsp)
46+
}
47+
48+
p := godpa.NewProxy(handlers)
49+
p.Run()
50+
```
51+
52+
53+
## License
54+
55+
[MIT](https://github.com/hhxsv5/go-db-proxy-api/blob/master/LICENSE)

0 commit comments

Comments
 (0)