From 5ce1b785fa468757f06a0597ee4118c894776506 Mon Sep 17 00:00:00 2001 From: a Date: Tue, 25 Oct 2022 04:05:28 -0500 Subject: [PATCH] go back to provided http server --- cmd/server/main.go | 16 +--------------- go.mod | 2 +- go.sum | 5 +++-- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 8f10b4b..3957e24 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -4,7 +4,6 @@ import ( "log" "net/http" "os" - "path" "strings" "time" @@ -34,20 +33,7 @@ func main() { r.Use(middleware.Recoverer) r.Use(middleware.SetHeader("Access-Control-Allow-Origin", "*")) - r.HandleFunc("/signatures/{hash}", func(w http.ResponseWriter, r *http.Request) { - lookup := path.Base(r.URL.Path) - if len(lookup) > 8 { - http.Error(w, "bad path", 400) - return - } - sig := sigs.Hex(lookup) - if sig == "" { - http.Error(w, "not found", 404) - return - } - w.WriteHeader(http.StatusOK) - w.Write([]byte(sig)) - }) + r.Handle("/signatures/{hash}", &sigs.HttpServer{}) FileServer(r, "/", filesDir) diff --git a/go.mod b/go.mod index 1687f44..bb775ce 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.19 replace github.com/tendermint/tendermint => github.com/bnb-chain/tendermint v0.31.12 require ( + gfx.cafe/open/4bytes v0.0.0-20221025085909-a307043c1e5e github.com/RoaringBitmap/roaring v1.2.1 github.com/go-chi/chi/v5 v5.0.7 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d @@ -20,7 +21,6 @@ require ( require ( crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508 // indirect - gfx.cafe/open/4bytes v0.0.0-20221025060640-c4301cc087ee // indirect github.com/VictoriaMetrics/fastcache v1.12.0 // indirect github.com/VictoriaMetrics/metrics v1.22.2 // indirect github.com/ajwerner/btree v0.0.0-20211221152037-f427b3e689c0 // indirect diff --git a/go.sum b/go.sum index fd52a9b..2371782 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ crawshaw.io/sqlite v0.3.2/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4= crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508 h1:fILCBBFnjnrQ0whVJlGhfv1E/QiaFDNtGFBObEVRnYg= crawshaw.io/sqlite v0.3.3-0.20210127221821-98b1f83c5508/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= -gfx.cafe/open/4bytes v0.0.0-20221025060640-c4301cc087ee h1:Wbz69Iw7rhp7UbCNeHs8lSkUoha9cHwvXz9gVZvD+Fg= -gfx.cafe/open/4bytes v0.0.0-20221025060640-c4301cc087ee/go.mod h1:2KCpg7z6U0ePqyX//YkaYEP9aJnmU5HoB6cnXVLR/d0= +gfx.cafe/open/4bytes v0.0.0-20221025085909-a307043c1e5e h1:Fl+QPNlTOVAxKqSEdut5fH+/To4TPE8kg8weQ3LGzUY= +gfx.cafe/open/4bytes v0.0.0-20221025085909-a307043c1e5e/go.mod h1:C0vwSYhh1b/ckPTkpq0kDXk32vU4DT5QuQwYLxO6W2c= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -475,6 +475,7 @@ github.com/openacid/must v0.1.3/go.mod h1:luPiXCuJlEo3UUFQngVQokV0MPGryeYvtCbQPs github.com/openacid/slim v0.5.11 h1:LIN8ktjSV5/0h9Wai9o30jpzQPPIYZmaRExmt9nGkPU= github.com/openacid/slim v0.5.11/go.mod h1:ddlyrp5csrPL30DlLp/SjgP4bdgCnmaCmmv4my407VI= github.com/openacid/tablewriter v0.0.0-20190429071406-b14f71081b86/go.mod h1:iJAvCLjVGFyZOV2Oh123q4PMcoBv2qQLEvjlVIM9E2E= +github.com/openacid/testkeys v0.1.6 h1:vuQZu/NM6nJo0OKUcaFNtm76Rnv3fMIIXrjp0gFX7FM= github.com/openacid/testkeys v0.1.6/go.mod h1:MfA7cACzBpbiwekivj8StqX0WIRmqlMsci1c37CA3Do= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=