contactform-slack

command module
v0.0.0-...-a903590 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

contactform-slack

Go Report Card

Send contact form input to Slack with email validation and GeoLite2 information

Features

  • Small web service
  • Validate email string
  • Block bad user-agent requests
  • JSON error messages
  • Block free email addresses
  • Parse GeoLite2 info for Slack message
  • Detect browser user-agent and is mobile
  • Send Slack message of contact information

Example Slack Message Contents

URL: localhost:8080/contact

Name: Tim Ski

Email: tim@someemail.com

Message: Love the site!

Browser: Chrome

Mobile: false

Country: United States

City: McLean

State: Virginia

Build

# Binary Build
make build

# Docker Build
make dbuild

## or

# Go build

CGO_ENABLED=0 go build -a -installsuffix cgo -o contactform-slack -ldflags -s -w .

# Create self-signed certs
openssl req -x509 -newkey rsa:4096 -nodes -keyout ./localhost.key -out ./localhost.pem -days 365 -sha256 -subj '/CN=localhost'

# Docker build
sudo docker build . -t perlogix:contactform-slack

Docker Run

./env-file format

SLACK_URL=https://hooks.slack.com/services/...
REDIRECT_URL=https://somesite.com/contact
GEOLITE_DB=./GeoLite2-City.mmdb
make drun

# or 

sudo docker run --name=contactform-slack -d -p 127.0.0.1:8080:8080 --env-file ./env-file --restart always perlogix:contactform-slack

Example Request

curl -k -XPOST -H 'User-Agent: test-message' -F 'email=tim@someemail.com' -F 'name=tim ski' -F 'message=whats up' https://localhost:8080/contact

Responses

{"error":"Email not valid"}
{"error":"Missing form information"}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址