Skip to content
Snippets Groups Projects
Unverified Commit a8e637cd authored by Philipp Winter's avatar Philipp Winter
Browse files

Use the flag package for command line arguments.

Thanks to Cecylia for suggesting this here:
<https://bugs.torproject.org/30472#comment:6>
parent 7943e9db
No related branches found
No related tags found
No related merge requests found
package main
import (
"fmt"
"flag"
"log"
"net/http"
"os"
"time"
"github.com/gorilla/mux"
......@@ -76,12 +75,19 @@ func Logger(inner http.Handler, name string) http.Handler {
// main is the entry point of this tool.
func main() {
if len(os.Args) != 3 {
fmt.Printf("Usage: %s CERT_FILE KEY_FILE\n", os.Args[0])
os.Exit(1)
var certFile string
var keyFile string
flag.StringVar(&certFile, "cert-file", "", "Path to the certificate to use, in .pem format.")
flag.StringVar(&keyFile, "key-file", "", "Path to the certificate's private key, in .pem format.")
flag.Parse()
if certFile == "" {
log.Fatalf("The -cert-file argument is required.")
}
if keyFile == "" {
log.Fatalf("The -key-file argument is required.")
}
certFile := os.Args[1]
keyFile := os.Args[2]
router := NewRouter()
log.Fatal(http.ListenAndServeTLS(":8080", certFile, keyFile, router))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment