Compare commits
2 Commits
52bc16436e
...
a4416164cd
| Author | SHA1 | Date | |
|---|---|---|---|
| a4416164cd | |||
| 67c27a6139 |
|
|
@ -26,7 +26,6 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"cloud.google.com/go/profiler"
|
|
||||||
"github.com/gomodule/redigo/redis"
|
"github.com/gomodule/redigo/redis"
|
||||||
|
|
||||||
"p83.nl/go/ekster/pkg/microsub"
|
"p83.nl/go/ekster/pkg/microsub"
|
||||||
|
|
@ -60,17 +59,6 @@ func newPool(addr string) *redis.Pool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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")
|
log.Println("eksterd - microsub server")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,13 @@ 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 {
|
if r.Method == http.MethodGet {
|
||||||
values := r.URL.Query()
|
values := r.URL.Query()
|
||||||
action := values.Get("action")
|
action := values.Get("action")
|
||||||
|
|
@ -74,6 +81,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
jw := json.NewEncoder(w)
|
jw := json.NewEncoder(w)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
|
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||||
err = jw.Encode(map[string][]microsub.Channel{
|
err = jw.Encode(map[string][]microsub.Channel{
|
||||||
"channels": channels,
|
"channels": channels,
|
||||||
})
|
})
|
||||||
|
|
@ -89,6 +97,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
jw := json.NewEncoder(w)
|
jw := json.NewEncoder(w)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
|
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||||
jw.SetIndent("", " ")
|
jw.SetIndent("", " ")
|
||||||
jw.SetEscapeHTML(false)
|
jw.SetEscapeHTML(false)
|
||||||
err = jw.Encode(timeline)
|
err = jw.Encode(timeline)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user