Open
Description
the following code is borrowed from this example..
I made a few minor changes, but I'm not familiar with the Go language.. so the syntax may be need some correction.
it could be applied to devd.go..
type HTTPHeaderValue http.Header
func (h HTTPHeaderValue) Set(value string) error {
parts := strings.SplitN(value, ":", 2)
if len(parts) != 2 {
return fmt.Errorf("expected 'HEADER:VALUE' got '%s'", value)
}
(http.Header)(h).Add(parts[0], parts[1])
return nil
}
func (h HTTPHeaderValue) String() string {
return ""
}
func (h HTTPHeaderValue) IsCumulative() bool {
return true
}
func HTTPHeader(s kingpin.Settings) (target *http.Header) {
target = &http.Header{}
s.SetValue((*HTTPHeaderValue)(target))
return
}
hdrs := HTTPHeader(kingpin.Flag("header", "Add HTTP response header").Short('H').PlaceHolder("HEADER:VALUE"))
if *cors {
hdrs.Set("Access-Control-Allow-Origin", "*")
}
the intention is to accept multiple CLI --header="name:value"
options
ex:
devd --header="Strict-Transport-Security:max-age=0" --header="Cache-Control:max-age=0" --port=443 --all --tls .
Metadata
Metadata
Assignees
Labels
No labels