Skip to content

Commit

Permalink
Enable CORS for the runner
Browse files Browse the repository at this point in the history
  • Loading branch information
kairichard committed Oct 30, 2019
1 parent 455b78a commit d07643c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/slang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/Bitspark/slang/pkg/core"
"github.com/Bitspark/slang/pkg/log"
"github.com/gorilla/mux"
"github.com/rs/cors"
)

var SupportedRunModes = []string{"process", "httpPost"}
Expand Down Expand Up @@ -148,11 +149,15 @@ func runHttpPost(operator *core.Operator, bind string) {

})

handler := cors.New(cors.Options{
AllowedMethods: []string{"POST"},
}).Handler(r)

operator.Main().Out().Bufferize()
operator.Start()
log.Print("started as httpPost")
go func() {
log.Fatal(http.ListenAndServe(bind, r))
log.Fatal(http.ListenAndServe(bind, handler))
}()
}

Expand Down

0 comments on commit d07643c

Please sign in to comment.