mirror of
https://github.com/minio/minio.git
synced 2025-11-21 10:16:03 -05:00
Add HTTP2 config option for policy plugin (#16225)
This commit is contained in:
committed by
GitHub
parent
709eb283d9
commit
9e6cc847f8
@@ -22,6 +22,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
@@ -29,6 +30,16 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
keyFile string
|
||||
certFile string
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&keyFile, "key-file", "", "Path to TLS cert key file")
|
||||
flag.StringVar(&certFile, "cert-file", "", "Path to TLS cert file")
|
||||
}
|
||||
|
||||
func writeErrorResponse(w http.ResponseWriter, err error) {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(map[string]string{
|
||||
@@ -77,8 +88,22 @@ func mainHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
serveFunc := func() error {
|
||||
return http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
||||
if certFile != "" || keyFile != "" {
|
||||
if certFile == "" || keyFile == "" {
|
||||
log.Fatal("Please provide both a key file and a cert file to enable TLS.")
|
||||
}
|
||||
serveFunc = func() error {
|
||||
return http.ListenAndServeTLS(":8080", certFile, keyFile, nil)
|
||||
}
|
||||
}
|
||||
|
||||
http.HandleFunc("/", mainHandler)
|
||||
|
||||
log.Print("Listening on :8080")
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
log.Fatal(serveFunc())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user