diff --git a/Dockerfile b/Dockerfile index 3aa69bf..a466acb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ -FROM golang:1.12 -WORKDIR /opt/dal +FROM golang:1.12 as build +WORKDIR /opt/vdc COPY . . RUN CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-w -s -X main.Build=$(git rev-parse --short HEAD)" -o mock-vdc + +FROM alpine +COPY --from=build /opt/vdc/mock-vdc /opt/vdc/mock-vdc EXPOSE 8080 -ENTRYPOINT [ "/opt/dal/mock-vdc" ,"--port","8080"] \ No newline at end of file +ENTRYPOINT [ "/opt/vdc/mock-vdc" ,"--port","8080"] \ No newline at end of file diff --git a/main.go b/main.go index 775c533..d90d11b 100644 --- a/main.go +++ b/main.go @@ -110,6 +110,7 @@ func (v *VDCServer) Router() *mux.Router { r := mux.NewRouter() r.Methods("GET").Path("/ask").Handler(http.HandlerFunc(v.ask)) + r.Methods("OPTIONS").Path("/ask").Handler(http.HandlerFunc(v.ask)) r.NotFoundHandler = http.HandlerFunc(v.notFound) return r } @@ -214,7 +215,7 @@ func (v *VDCServer) notFound(w http.ResponseWriter, r *http.Request) { func (v *VDCServer) ask(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD") - w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, Authorization, X-DITAS-CALLBACK") + w.Header().Set("Access-Control-Allow-Headers", "*") v.Log(fmt.Sprintf("[%s] %s", r.Method, r.RequestURI)) v.Trace(r, "vdc-request")