cloudhttp

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 12 Imported by: 0

README

GoDoc

cloudhttp

Easily setup a HTTPs server on most cloud providers (aws, gcp, etc) without having to worry about much of anything.

Each server will automatically get a dynamic .g-dns.net domain for the SSL certificate.

Usage

mux := http.NewServeMux()
// setup mux handlers
err := cloudhttp.Serve(mux)
if err != nil {
    // ...
}

With just this code, a http/https server will start and will have a valid SSL certificate, provided the host's IP address is publicly accessible and port 443 isn't blocked from outside.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerHost string

ServerHost is filled when calling Serve() and will contain the hostname that was generated for this machine

Functions

func HostnameForIP

func HostnameForIP(ip net.IP) string

HostnameForIP returns a hostname for the given ipv4

func HttpsRedirectorServer

func HttpsRedirectorServer(proto, ip, targetHost string) error

HttpsRedirectorServer launches a redirector and serves serves requests in a separate goroutine.

func Serve

func Serve(h http.Handler) error

Serve is a simple function that will listen on http/https ports, and redirect all http requests to the right https host.

Types

type HttpsRedirector

type HttpsRedirector string

HttpsRedirector is a http.Handler that will redirect all requests it receives to the specified host as https.

func (HttpsRedirector) ServeHTTP

func (h HttpsRedirector) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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