autotls

package module
v0.0.0-...-cbf4205 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2018 License: MIT Imports: 3 Imported by: 4

README

autotls

Build Status CircleCI Status codecov Go Report Card GoDoc

Support Let's Encrypt for a Go server application, based on autotls.

examples

example for 1-line LetsEncrypt HTTPS servers.

package main

import (
	"log"

	"github.com/go-ego/autotls"
	"github.com/go-ego/ego"
)

func main() {
	r := ego.Default()

	// Ping handler
	r.GET("/ping", func(c *ego.Context) {
		c.String(200, "pong")
	})

	log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
}

example for custom autocert manager.

package main

import (
	"log"

	"github.com/go-ego/autotls"
	"github.com/go-ego/ego"
	"golang.org/x/crypto/acme/autocert"
)

func main() {
	r := ego.Default()

	// Ping handler
	r.GET("/ping", func(c *ego.Context) {
		c.String(200, "pong")
	})

	m := autocert.Manager{
		Prompt:     autocert.AcceptTOS,
		HostPolicy: autocert.HostWhitelist("example1.com", "example2.com"),
		Cache:      autocert.DirCache("/var/www/.cache"),
	}

	log.Fatal(autotls.RunWithManager(r, &m))
}

Documentation

Overview

Package autotls support Let's Encrypt for a Go server application.

package main

import (
	"log"

	"github.com/go-ego/autotls"
	"github.com/go-ego/ego"
)

func main() {
	r := ego.Default()

	// Ping handler
	r.GET("/ping", func(c *ego.Context) {
		c.String(200, "pong")
	})

	log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(r http.Handler, domain ...string) error

Run support 1-line LetsEncrypt HTTPS servers

func RunWithManager

func RunWithManager(r http.Handler, m *autocert.Manager) error

RunWithManager support custom autocert manager

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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