Name (graceful/http.go)

doco-cd · internal/graceful/http.go · go · Apache-2.0
infra, tag:knn-classified

Module exposing: Name, Shutdown, Serve, NewHttpServer, graceHttpServer

// Source: https://github.com/kimdre/doco-cd | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package graceful

import (
	"context"
	"errors"
	"fmt"
	"net"
	"net/http"
)

type graceHttpServer struct {
	name        string
	server      *http.Server
	tlsCertFile string
	tlsKeyFile  string
}

func (s *graceHttpServer) Name() string {
	return s.name
}

func (s *graceHttpServer) Shutdown(ctx context.Context) error {
	return s.server.Shutdown(ctx)
}

func (s *graceHttpServer) Serve(ctx context.Context) error {
	s.server.BaseContext = func(_ net.Listener) context.Context {
		return ctx
	}

	var err error

	switch {
	case s.tlsCertFile != "" && s.tlsKeyFile != "":
		err = s.server.ListenAnd

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key