Skip to content

Instantly share code, notes, and snippets.

@weaming
Created March 10, 2022 08:39
Show Gist options
  • Select an option

  • Save weaming/c8ada49de7c92b9e26f65acd096f7cc2 to your computer and use it in GitHub Desktop.

Select an option

Save weaming/c8ada49de7c92b9e26f65acd096f7cc2 to your computer and use it in GitHub Desktop.

Revisions

  1. weaming created this gist Mar 10, 2022.
    25 changes: 25 additions & 0 deletions mock-tdengine-not-ready.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    package main

    import (
    "io/ioutil"
    "log"
    "net/http"
    )

    func index(w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(http.StatusOK)
    w.Write([]byte(`{"status": "error", "code": 20, "desc": "Database not ready"}`))
    if r.Body != nil {
    req, e := ioutil.ReadAll(r.Body)
    if e != nil {
    panic(e)
    }
    log.Println("request body:", string(req))
    }
    }

    func main() {
    http.HandleFunc("/", index)
    log.Println("listen 127.0.0.1:8080")
    http.ListenAndServe(":8080", nil)
    }