Compare commits
No commits in common. "a4416164cd1e20ed45b43e3ed39a8ab10ecc0f19" and "52bc16436edce8754b70296a2bc647a0129c785d" have entirely different histories.
a4416164cd
...
52bc16436e
|
|
@ -26,6 +26,7 @@ import (
|
|||
"regexp"
|
||||
"time"
|
||||
|
||||
"cloud.google.com/go/profiler"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
|
||||
"p83.nl/go/ekster/pkg/microsub"
|
||||
|
|
@ -59,6 +60,17 @@ func newPool(addr string) *redis.Pool {
|
|||
}
|
||||
|
||||
func main() {
|
||||
|
||||
if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") != "" {
|
||||
if err := profiler.Start(profiler.Config{
|
||||
Service: "microsub-server",
|
||||
ServiceVersion: "1.0",
|
||||
ProjectID: "microsub-server", // optional on GCP
|
||||
}); err != nil {
|
||||
log.Fatalf("Cannot start the profiler: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("eksterd - microsub server")
|
||||
flag.Parse()
|
||||
|
||||
|
|
|
|||
|
|
@ -63,13 +63,6 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
if r.Method == http.MethodOptions {
|
||||
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Add("Access-Control-Allow-Methods", "GET, POST")
|
||||
w.Header().Add("Access-Control-Allow-Headers", "Authorization")
|
||||
return
|
||||
}
|
||||
|
||||
if r.Method == http.MethodGet {
|
||||
values := r.URL.Query()
|
||||
action := values.Get("action")
|
||||
|
|
@ -81,7 +74,6 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
jw := json.NewEncoder(w)
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||
err = jw.Encode(map[string][]microsub.Channel{
|
||||
"channels": channels,
|
||||
})
|
||||
|
|
@ -97,7 +89,6 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
jw := json.NewEncoder(w)
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||
jw.SetIndent("", " ")
|
||||
jw.SetEscapeHTML(false)
|
||||
err = jw.Encode(timeline)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user