From a5a8a126e2306f0ba0bfc6b0f7037d646c694ac3 Mon Sep 17 00:00:00 2001 From: Manish R Jain <manish@dgraph.io> Date: Tue, 17 May 2016 18:12:26 +1000 Subject: [PATCH] Have a flag to forbit mutations on a server. Very useful for the live demo, or other read-only situations. --- server/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/main.go b/server/main.go index 3d399e4c..51db34f9 100644 --- a/server/main.go +++ b/server/main.go @@ -56,6 +56,7 @@ var instanceIdx = flag.Uint64("instanceIdx", 0, "serves only entities whose Fingerprint % numInstance == instanceIdx.") var workers = flag.String("workers", "", "Comma separated list of IP addresses of workers") +var nomutations = flag.Bool("nomutations", false, "Don't allow mutations on this server.") func addCorsHeaders(w http.ResponseWriter) { w.Header().Set("Access-Control-Allow-Origin", "*") @@ -68,6 +69,10 @@ func addCorsHeaders(w http.ResponseWriter) { } func mutationHandler(mu *gql.Mutation) error { + if *nomutations { + return fmt.Errorf("Mutations are forbidden on this server.") + } + r := strings.NewReader(mu.Set) scanner := bufio.NewScanner(r) var nquads []rdf.NQuad -- GitLab