Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hhxsv5/go-db-proxy-api
A simple http API is used to connect the database which is in private/intranet network.
https://github.com/hhxsv5/go-db-proxy-api
proxy-database proxy-mssql proxy-mysql proxy-server
Last synced: about 1 month ago
JSON representation
A simple http API is used to connect the database which is in private/intranet network.
- Host: GitHub
- URL: https://github.com/hhxsv5/go-db-proxy-api
- Owner: hhxsv5
- License: mit
- Created: 2017-11-22T06:20:18.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-19T10:49:28.000Z (about 7 years ago)
- Last Synced: 2024-10-15T08:46:40.653Z (3 months ago)
- Topics: proxy-database, proxy-mssql, proxy-mysql, proxy-server
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Database Proxy API
==================A simple http API is used to connect the database which is in private/intranet network.
## Usage
1. Install
```Shell
//cd your-root-folder-of-project
//Create the file glide.yaml if not exist
//touch glide.yaml
glide get github.com/hhxsv5/go-db-proxy-api#~1.0.0
```2. Config
- config of database: config/db.toml
- config of http server: config/http.toml3. Run
```Go
var handlers = map[string]func(w http.ResponseWriter, r *http.Request){}
handlers["/"] = func(w http.ResponseWriter, r *http.Request) {
//rand.Seed(time.Now().UnixNano())
//cellphone := "1878020" + strconv.Itoa(int(1000+rand.Int31n(9999-1000)))
//mydefault.CreateUser(cellphone)users := mydefault.GetUsersByIds([]uint64{})
var (
rsp string
it time.Time
mt time.Time
)for i, u := range users {
it = time.Unix(u.InsertTime, 0)
mt = time.Unix(u.ModifyTime, 0)
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"))
}io.WriteString(w, rsp)
}p := godpa.NewProxy(handlers)
p.Run()
```## Thanks [ORM](https://github.com/go-xorm/xorm)
## License
[MIT](https://github.com/hhxsv5/go-db-proxy-api/blob/master/LICENSE)