Skip to content

Commit

Permalink
start rewritting to go to check performance diff
Browse files Browse the repository at this point in the history
  • Loading branch information
n0npax committed May 22, 2020
1 parent 67138bc commit 78e0a52
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/n0npax/sidecar_http_dispatcher

go 1.13

require github.com/go-chi/chi v4.1.1+incompatible
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/go-chi/chi v4.1.1+incompatible h1:MmTgB0R8Bt/jccxp+t6S/1VGIKdJw5J74CK/c9tTfA4=
github.com/go-chi/chi v4.1.1+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
28 changes: 28 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"net/http"

"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
)

func main() {
r := chi.NewRouter()
r.Use(middleware.RequestID)
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
client := &http.Client{}

r.Get("/", func(w http.ResponseWriter, r *http.Request) {
req, err := http.NewRequest("GET", "http://example.com", nil)
if err != nil {
panic("cannot create a req")
}
resp, _ := client.Do(req)
w.Write([]byte(fmt.Sprintf("%v", resp)))
})

http.ListenAndServe(":3333", r)
}

0 comments on commit 78e0a52

Please sign in to comment.