File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,23 @@ package main
22
33import (
44 "github.com/hhxsv5/go-db-proxy-api"
5+ "time"
6+ "io"
7+ "net/http"
58)
69
710func main () {
811 //user := mydefault.CreateUser("18780207350")
912 //fmt.Println(user)
1013 //fmt.Printf("%p", user)
1114
12- p := godpa .NewProxy ()
15+ var handlers = map [string ]func (w http.ResponseWriter , r * http.Request ){}
16+ handlers ["/" ] = func (w http.ResponseWriter , r * http.Request ) {
17+ response := "Hello http server by golang!\n "
18+ response += "Now: " + time .Now ().String () + "\n "
19+ io .WriteString (w , response )
20+ }
21+
22+ p := godpa .NewProxy (handlers )
1323 p .Run ()
1424}
Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ package godpa
33import (
44 "github.com/hhxsv5/go-db-proxy-api/http"
55 nhttp "net/http"
6- "time"
7- "io"
86)
97
108type Proxy struct {
@@ -15,14 +13,7 @@ func (p *Proxy) Run() {
1513 p .server .Run ()
1614}
1715
18- func NewProxy () * Proxy {
19- var handlers = map [string ]func (w nhttp.ResponseWriter , r * nhttp.Request ){}
20- handlers ["/" ] = func (w nhttp.ResponseWriter , r * nhttp.Request ) {
21- response := "H" +
22- "ello http server by golang!\n "
23- response += "Now: " + time .Now ().String () + "\n "
24- io .WriteString (w , response )
25- }
16+ func NewProxy (handlers map [string ]func (w nhttp.ResponseWriter , r * nhttp.Request )) * Proxy {
2617 s := http .NewServer (handlers )
2718 return & Proxy {s }
2819}
You can’t perform that action at this time.
0 commit comments