Go
DataDome Go Integration build detects and protects against bot activity
This Datadome module is to be used on Go platform.
Installation
Requirements
datadome_server_side_key
available in your DataDome dashboard
Protect your traffic
- 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}
- Import DataDome module inside your Go project
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
"datadome.co/go-core/datadome"
)
- Update 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
- Create a DataDome function and replace replace
DATADOME_SERVER_SIDE_KEY
with the value of yourDATADOME_SERVER_SIDE_KEY
coming 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)
}
- 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")
}
- 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
Updated about 1 month ago