init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
const usage = "servetls <cert file> <key file>"
|
||||
const port = 8443
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 3 {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", usage)
|
||||
os.Exit(1)
|
||||
}
|
||||
cert, key := os.Args[1], os.Args[2]
|
||||
|
||||
http.HandleFunc("/", handler)
|
||||
|
||||
addr := fmt.Sprintf(":%d", port)
|
||||
fmt.Printf("serving on %s", addr)
|
||||
err := http.ListenAndServeTLS(addr, cert, key, nil)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func handler(w http.ResponseWriter, req *http.Request) {
|
||||
fmt.Fprintf(w, "if you see this without complaints things are likely set up correctly\n")
|
||||
}
|
||||
Reference in New Issue
Block a user