Go

DataDome Go Integration build detects and protects against bot activity

This Datadome module is to be used on Go platform.

Installation

Requirements

Protect your traffic

  1. Download our Tyk module (wrote in Go) it, extract it and copy the whole go-core folder to your project:
wget https://package.datadome.co/cloud/DataDome-Tyk-latest.tgz
tar -xzvf https://package.datadome.co/cloud/DataDome-Tyk-latest.tgz
cp -r go-core ${YOUR_PROJECT}  ${GOPATH}/src/${YOUR_PROJECT}
  1. Import DataDome module inside your Go project
import (
	"fmt"
	"log"
	"net/http"
	"github.com/gorilla/mux"
	"datadome.co/go-core/datadome"
)
  1. Use a the require statement and the replace/add it, inside the go.mod file :
require (  
	datadome.co/go-core v0.0.0-00010101000000-000000000000  
	github.com/gorilla/mux v1.8.1  
)
require github.com/google/go-querystring v1.1.0 // indirect

replace ./go-core
  1. Create a DataDome function and replace replace DATADOME_SERVER_SIDE_KEY with the value of your DATADOME_SERVER_SIDE_KEYcoming from the Dashboard
func DataDome(w http.ResponseWriter, r \*http.Request) (bool, error) {  
	var dd = &datadome.DataDomeStruct{  
		DatadomeServerSideKey: "DATADOME_SERVER_SIDE_KEY",  
		ModuleName:            "Golang",  
	}  
	return dd.DatadomeProtect(w, r)  
}
  1. Add it to your handler/middleware, for example:
func HomeHandler(w http.ResponseWriter, r \*http.Request) {  
	//var isBlocked, err = DataDome(w,r)  
	var \_, err = DataDome(w,r)
	if err != nil {
		fmt.Println("DataDome error ", err.Error())
	}

	fmt.Fprintf(w, "Welcome to the home page!\n")
}
  1. Re-compile your code

Congrats! You can now see your traffic in your DataDome dashboard.

Configuration

Please reach out to our support team if you want set up specific configuration