How we used Go and CGI to build a self-contained form processor with bot protection, input sanitization, email delivery, and JSON responses.
Modern web development often assumes that running backend functionality requires a dedicated server, an application runtime, or an external service.
But what if you could deliver a complete, secure form-processing backend using nothing more than a single compiled binary on traditional shared hosting?
That was the idea behind this project.
We built a lightweight form processor in Go, compiled it into a standalone executable, and deployed it as a CGI application. It handles the entire form-submission lifecycle, including request processing, input sanitization, spam and bot protection, email delivery, and JSON responses.
No persistent application server. No additional runtime dependencies. No external SMTP service required.
Just a Go binary running in an environment that has traditionally been associated with PHP scripts.
Forms are among the most common features on websites, but processing them securely can introduce surprising complexity.
A seemingly simple contact form needs more than an endpoint that accepts a POST request.
A production-ready implementation should consider:
For developers using static websites or traditional shared hosting, these requirements can be particularly inconvenient.
Many solutions introduce external dependencies, third-party form-processing services, dedicated application servers, or additional infrastructure.
We wanted something simpler.
Rather than building another continuously running web service, we chose Go and the Common Gateway Interface (CGI).
Go provides a convenient way to compile an application into a standalone executable. CGI provides a standardized interface through which a web server can execute that application when a request arrives.
Combining the two gave us an interesting deployment model:
There is no need to install Go on the production server or maintain a persistent application process.
This makes the solution particularly interesting for traditional shared hosting environments.
The application is designed to handle the entire submission process rather than delegating individual responsibilities to external services.
The CGI application receives incoming form submissions and processes the request.
It handles the submitted data and prepares it for validation.
Public forms are frequent targets for automated submissions.
The application incorporates built-in anti-spam and bot-protection mechanisms to help identify and reject unwanted submissions.
Having these protections integrated into the processor means developers don’t need to assemble a collection of unrelated services just to protect a contact form.
Incoming data is validated and sanitized before being used.
This is an important part of the processing pipeline, helping prevent malformed or unexpected input from being passed into subsequent operations.
Validation and sanitization are treated as separate responsibilities rather than assuming that cleaning an input automatically makes it safe in every context.
One of the practical design decisions was to use the hosting server’s local sendmail interface for email delivery.
This avoids requiring the application to establish an external SMTP connection.
That can be particularly useful on shared hosting platforms where outbound SMTP connections may be restricted or where developers don’t have access to external mail-service credentials.
Email delivery still depends on the hosting provider’s mail configuration and sending policies, but it removes another external infrastructure dependency from the application.
After processing a submission, the application returns a JSON response.
This makes the backend independent of the frontend implementation.
A traditional HTML form, a JavaScript-powered website, or a static site can communicate with the same processor without needing to understand its internal implementation.
The frontend simply submits the data and handles the returned response.
The overall architecture is intentionally straightforward.
The important distinction is that all backend responsibilities are handled by the same executable.
There is no separate application server, email API integration, or external form-processing platform in the request pipeline.
A persistent Go HTTP server would certainly be a valid approach. It is often preferable for applications handling substantial traffic or requiring long-lived connections.
However, it also introduces operational requirements.
A traditional application server generally needs a process that remains running, along with an appropriate hosting environment and a way to manage that process.
CGI takes a different approach.
The web server launches the executable when a request arrives. The application processes the request and exits when finished.
This has some trade-offs, particularly process startup overhead and the lack of persistent in-memory application state.
But for relatively lightweight form processing, this can be a reasonable compromise.
The objective wasn’t to replace every backend architecture. It was to make a useful piece of backend functionality deployable in a much wider range of hosting environments.
Perhaps the most interesting aspect of this project is its deployment model.
Traditional shared hosting often provides limited control over the server environment.
Developers may not have access to install additional runtimes, configure persistent services, or run custom application servers.
A compiled Go executable changes that equation.
Provided the hosting environment supports CGI execution and permits the required executable permissions, deployment can be relatively straightforward.
The application doesn’t require the hosting provider to install Go, Node.js, Python, or another application runtime.
The result is a modern compiled backend running on infrastructure that many developers already have access to.
The architecture offers several practical advantages.
Minimal deployment footprint
The application is distributed as a compiled executable rather than a collection of scripts and runtime dependencies.
No persistent application server
CGI execution eliminates the need to maintain a continuously running application process.
Built-in protection
Spam and bot protection are part of the application rather than separate services that need to be integrated.
Simplified email delivery
Using the server’s local sendmail interface avoids depending on an external SMTP connection.
Frontend independence
JSON responses make the processor usable with different frontend technologies.
Hosting flexibility
The solution can run on compatible traditional shared hosting environments without requiring a dedicated VPS or container platform.
CGI isn’t necessarily the right architecture for every application.
Because the web server launches a new process for each request, there is startup overhead compared with a persistent application server.
Other considerations include:
Understanding these limitations is important.
The goal is not to claim that CGI is universally superior, but to demonstrate that it remains a useful and practical interface for certain kinds of backend applications.
This project started with a relatively simple objective: build a reliable form processor that could be deployed without requiring a dedicated backend server.
The result is a self-contained Go application that handles request processing, spam and bot protection, input sanitization, email delivery, and JSON responses.
By combining Go’s compilation model with the long-established CGI interface, we found a way to bring modern backend functionality to traditional shared hosting.
It is a reminder that modern web development doesn’t always require more infrastructure.
Sometimes, a well-designed executable and a compatible web server are enough.
A complete backend doesn’t always need a backend server.