summaryrefslogtreecommitdiffstats
path: root/library/cpp/http/simple/ut/https_server/main.go
diff options
context:
space:
mode:
authorkomels <[email protected]>2022-04-15 16:53:39 +0300
committerkomels <[email protected]>2022-04-15 16:53:39 +0300
commit703a2fb6e100d202d1c7fcd052d73bd5affef408 (patch)
tree22b7320c06bb04d86dbf7b9af9ae44281331cd15 /library/cpp/http/simple/ut/https_server/main.go
parent3375bbfda1e2afb03aa2072bf5f2f2c3a26026e8 (diff)
Move 'kikimr/yndx'-depending tests out of ydb/core
ref:0a380e13308d579e0545a76924330d1ca5129c43
Diffstat (limited to 'library/cpp/http/simple/ut/https_server/main.go')
-rw-r--r--library/cpp/http/simple/ut/https_server/main.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/library/cpp/http/simple/ut/https_server/main.go b/library/cpp/http/simple/ut/https_server/main.go
deleted file mode 100644
index 4282810675e..00000000000
--- a/library/cpp/http/simple/ut/https_server/main.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package main
-
-import (
- "fmt"
- "log"
- "net/http"
- "os"
-
- "github.com/spf13/cobra"
- "github.com/spf13/pflag"
-)
-
-type Opts struct {
- Port uint16
- KeyFile string
- CertFile string
-}
-
-func handler(writer http.ResponseWriter, request *http.Request) {
- res := "pong.my"
-
- writer.Header().Set("Content-Type", "text/plain")
- writer.WriteHeader(http.StatusOK)
-
- _, _ = writer.Write([]byte(res))
-}
-
-func runServer(opts *Opts) error {
- mainMux := http.NewServeMux()
- mainMux.Handle("/ping", http.HandlerFunc(handler))
-
- server := &http.Server{
- Addr: fmt.Sprintf("localhost:%d", opts.Port),
- Handler: mainMux,
- ErrorLog: log.New(os.Stdout, "", log.LstdFlags),
- }
-
- return server.ListenAndServeTLS(opts.CertFile, opts.KeyFile)
-}
-
-func markFlagRequired(flags *pflag.FlagSet, names ...string) {
- for _, n := range names {
- name := n
- if err := cobra.MarkFlagRequired(flags, name); err != nil {
- panic(err)
- }
- }
-}
-
-func main() {
- opts := Opts{}
-
- cmd := cobra.Command{
- RunE: func(cmd *cobra.Command, args []string) error {
- return runServer(&opts)
- },
- }
-
- flags := cmd.Flags()
- flags.Uint16Var(&opts.Port, "port", 0, "")
- flags.StringVar(&opts.KeyFile, "keyfile", "", "path to key file")
- flags.StringVar(&opts.CertFile, "certfile", "", "path to cert file")
-
- markFlagRequired(flags, "port", "keyfile", "certfile")
-
- if err := cmd.Execute(); err != nil {
- _, _ = fmt.Fprintf(os.Stderr, "Exit with err: %s", err)
- os.Exit(1)
- }
-}