Skip to content

A simple http API is used to connect the database which is in private/intranet network.

License

Notifications You must be signed in to change notification settings

hhxsv5/go-db-proxy-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database Proxy API

A simple http API is used to connect the database which is in private/intranet network.

Usage

  1. Install
//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
  1. Config
  • config of database: config/db.toml
  • config of http server: config/http.toml
  1. Run
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

License

MIT

About

A simple http API is used to connect the database which is in private/intranet network.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages