https

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package https provides utilities for configuring and running HTTP servers over TLS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedirectHandler

func RedirectHandler(h http.Handler) http.Handler

RedirectHandler takes an http.Handler and returns a secured form of it.

func Serve

func Serve(handler http.Handler, cfg Config, opts ...func(*http.Server)) error

Serve starts an HTTP server configured to handle traffic directly from an ELB on port and terminate TLS using serverCert and serverKey.

Types

type Config

type Config struct {
	InsecurePort int `env:"HEROKU_ROUTER_HTTP_PORT,required"`
	SecurePort   int `env:"HEROKU_ROUTER_HTTPS_PORT,required"`

	// These environment variables are automatically set by ACM in
	// relation to Let's Encrypt certificates.
	ServerCert  string `env:"SERVER_CERT,required"`
	ServerKey   string `env:"SERVER_KEY,required"`
	UseAutocert bool   `env:"HTTPS_USE_AUTOCERT"`
	// These environment variables are set with default values of 60s
	ReadTimeout  time.Duration `env:"HTTP_SERVER_READ_TIMEOUT,default=60s"`
	WriteTimeout time.Duration `env:"HTTP_SERVER_WRITE_TIMEOUT,default=60s"`
}

Config for HTTP and HTTPS servers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL