Commit bb1561b 1 parent 6a3364b commit bb1561b Copy full SHA for bb1561b
File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 6
6
"os"
7
7
"time"
8
8
9
+ "net/http"
10
+
9
11
"github.com/bhoriuchi/go-bunyan/bunyan"
10
12
"github.com/cjimti/gin-bunyan"
11
13
"github.com/cjimti/rxtx/rtq"
@@ -68,9 +70,18 @@ func main() {
68
70
// use bunyan logger
69
71
r .Use (ginbunyan .Ginbunyan (& blog ))
70
72
71
- r .POST ("/rx/:producer/:key/*label" , rtq .RxRouteHandler )
73
+ rxRoute := "/rx/:producer/:key/*label"
74
+ r .POST (rxRoute , rtq .RxRouteHandler )
75
+ r .OPTIONS (rxRoute , preflight )
72
76
73
77
blog .Info ("Listening on port %s" , * port )
74
78
// block on server run
75
79
r .Run (":" + * port )
76
80
}
81
+
82
+ // CORS
83
+ func preflight (c * gin.Context ) {
84
+ c .Header ("Access-Control-Allow-Origin" , "*" )
85
+ c .Header ("Access-Control-Allow-Headers" , "access-control-allow-origin, access-control-allow-headers" )
86
+ c .JSON (http .StatusOK , struct {}{})
87
+ }
You can’t perform that action at this time.
0 commit comments