style: format code

This commit is contained in:
Kevin Franklin Kim 2021-11-15 15:42:36 +01:00
parent 51b33b1006
commit 49b59ea987
5 changed files with 18 additions and 19 deletions

View File

@ -33,7 +33,6 @@ func main() {
webserverPath := config.DefaultWebserverPath(c)
backendURL := config.DefaultBackendURL(c)
// create proxy
proxy, _ := proxy.NewProxy(
context.Background(),

View File

@ -3,9 +3,9 @@ package log
import "go.uber.org/zap"
const (
ServiceRoutineKey = "service_routine"
CacheIdKey = "cache_id"
URLKey = "url"
ServiceRoutineKey = "service_routine"
CacheIdKey = "cache_id"
URLKey = "url"
NumberOfWaitingClientsKey = "num_waiting_clients"
)

View File

@ -3,13 +3,14 @@ package proxy
import (
"crypto/md5"
"encoding/hex"
"github.com/foomo/contentfulproxy/packages/go/log"
"go.uber.org/zap"
"io/ioutil"
"net/http"
"sort"
"strings"
"sync"
"github.com/foomo/contentfulproxy/packages/go/log"
"go.uber.org/zap"
)
type cacheID string

View File

@ -3,9 +3,10 @@ package proxy
import (
"context"
"encoding/json"
"github.com/foomo/contentfulproxy/packages/go/log"
"net/http"
"github.com/foomo/contentfulproxy/packages/go/log"
"go.uber.org/zap"
)

View File

@ -2,21 +2,22 @@ package proxy
import (
"context"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"io/ioutil"
"net/http"
"net/http/httptest"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
)
const (
responseFoo = `i am a foo response`
responseBar = `i am bar response`
responseFoo = `i am a foo response`
responseBar = `i am bar response`
responseUpdate = `update`
responseFlush = `update`
responseFlush = `update`
)
type getStats func(path string) int
@ -82,7 +83,6 @@ func GetWebHook(t *testing.T) (getStats, http.HandlerFunc) {
}
func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string) int, s *httptest.Server) {
l, _ := zap.NewProduction()
gs, backendHandler := GetBackend(t)
@ -93,8 +93,8 @@ func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string)
p, _ := NewProxy(
context.Background(),
l,
func() string {return backendServer.URL},
func() string {return ""},
func() string { return backendServer.URL },
func() string { return "" },
func() []string {
return []string{
webHookServer.URL + "/test1",
@ -105,7 +105,6 @@ func getTestServer(t *testing.T) (gs func(path string) int, ws func(path string)
s = httptest.NewServer(p)
t.Log("we have a proxy in front of it running on", s.URL)
return gs, ws, s
}
func TestProxy(t *testing.T) {
@ -132,10 +131,9 @@ func TestProxy(t *testing.T) {
}
assert.Equal(t, 1, gs("/foo"))
// check the current status
//response, err := http.Get(server.URL + "/info")
//assert.NoError(t, err)
// response, err := http.Get(server.URL + "/info")
// assert.NoError(t, err)
//
_, _ = http.Get(server.URL + "/update")