INNER CODE UNIT · Go

demoMiddleware

Zeus-Labs/ZeusCloud · backend/main.go:23

func demoMiddleware(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if os.Getenv("MODE") == constants.DemoEnvModeStr {
			if r.Method == http.MethodPost || r.Method == http.MethodPut || r.Method == http.MethodDelete {
				http.Error(w, "Demo Mode Not Allowed", http.StatusForbidden)
				return
			}
		}
		next.ServeHTTP(w, r)
	})
}

func main() {
	log.Printf("Mode: %v", os.Getenv("MODE"))

	// Connect with Postgres database
	postgresDb := db.InitPostgres()
	log.Println("Set up postgres db")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…