mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 18:15:42 +01:00
Add hint if provider is called outside of CGI
Co-authored-by: Sascha L. Teichmann <sascha.teichmann@intevation.de>
This commit is contained in:
parent
f8ce08a26e
commit
38d3679704
1 changed files with 13 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cgi"
|
"net/http/cgi"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/csaf-poc/csaf_distribution/util"
|
"github.com/csaf-poc/csaf_distribution/util"
|
||||||
"github.com/jessevdk/go-flags"
|
"github.com/jessevdk/go-flags"
|
||||||
|
|
@ -22,6 +23,16 @@ type options struct {
|
||||||
Version bool `long:"version" description:"Display version of the binary"`
|
Version bool `long:"version" description:"Display version of the binary"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cgiRequired = "The csaf_provider is a cgi binary and is designed to be served via a web server."
|
||||||
|
|
||||||
|
func ensureCGI() {
|
||||||
|
if _, ok := os.LookupEnv("REQUEST_METHOD"); !ok {
|
||||||
|
fmt.Println(cgiRequired)
|
||||||
|
fmt.Println("Version: " + util.SemVersion)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var opts options
|
var opts options
|
||||||
parser := flags.NewParser(&opts, flags.Default)
|
parser := flags.NewParser(&opts, flags.Default)
|
||||||
|
|
@ -31,6 +42,8 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensureCGI()
|
||||||
|
|
||||||
cfg, err := loadConfig()
|
cfg, err := loadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cgi.Serve(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
cgi.Serve(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue