package https

import "golang.org/x/build/internal/https"

Package https contains helpers for starting an HTTP/HTTPS server.

Index

Variables

var DefaultOptions = &Options{}

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, handler http.Handler) error

ListenAndServe runs the servers configured by DefaultOptions. It always returns a non-nil error.

func ListenAndServeOpts

func ListenAndServeOpts(ctx context.Context, handler http.Handler, opts *Options) error

ListenAndServeOpts runs the servers configured by opts. It always returns a non-nil error.

func RegisterFlags

func RegisterFlags(set *flag.FlagSet)

RegisterFlags registers flags that control DefaultOptions, which will be used with ListenAndServe below. Typical usage is to call RegisterFlags at the beginning of main, then ListenAndServe at the end.

Types

type Options

type Options struct {
	// Specifies the ACME directory to use to retrieve certificates.
	AutocertDirectory string
	// Specifies the ACME external account binding token to use. This should be
	// a JSON-encoded acme.ExternalAccountBinding struct.
	AutocertEAB string
	// Specifies the GCS bucket to use with AutocertAddr.
	AutocertBucket string
	// If non-empty, listen on this address and serve HTTPS using a cert stored in AutocertBucket.
	AutocertAddr string
	// Specifies the email address to use when creating an ACME account.
	AutocertEmail string
	// If non-empty, listen on this address and serve HTTPS using a self-signed cert.
	SelfSignedAddr string
	// If non-empty, listen on this address and serve HTTP.
	HTTPAddr string
	// If non-empty, respond unconditionally with 200 OK to requests on this path.
	HealthPath string
}

Source Files

https.go

Version
v0.0.0-20250421191922-3619c213cff3 (latest)
Published
Apr 21, 2025
Platform
linux/amd64
Imports
20 packages
Last checked
3 months ago

Tools for package owners.