https

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

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

Go to latest
Published: Feb 18, 2020 License: MIT Imports: 17 Imported by: 5

README

https-go GoDoc

Quickly create a self-signed Go HTTPS server.

the project to show your appreciation.

Example

package main

import (
	"log"
	"net/http"
	"github.com/rocketlaunchr/https-go"
)

func main() {

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) })

	httpServer, _ := https.Server("8080", https.GenerateOptions{Host: "thecucumber.app"})
	log.Fatal(httpServer.ListenAndServeTLS("", ""))
}
Extra Notes

Just remember to change the url from http to https. Also configure your http client code/application to allow self-signed certificates otherwise they will spit out an error.

Other useful packages

  • dataframe-go - Statistics and data manipulation
  • dbq - Zero boilerplate database operations for Go
  • electron-alert - SweetAlert2 for Electron Applications
  • igo - A Go transpiler with cool new syntax such as fordefer (defer for for-loops)
  • mysql-go - Properly cancel slow MySQL queries
  • react - Build front end applications using Go
  • remember-go - Cache slow database queries

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Server

func Server(port string, opts GenerateOptions) (*http.Server, error)

Server will create a self-signed https server.

Example:

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) })

opts := GenerateOptions{Host: "domain.com"}
httpServer, _ := Server("8080", opts)
log.Fatal(httpServer.ListenAndServeTLS("", ""))

Types

type GenerateOptions

type GenerateOptions struct {

	// Comma-separated hostnames and IPs to generate a certificate for.
	Host string

	// Creation date formatted as "Jan 1 15:04:05 2011".
	// Default is time.Now().
	ValidFrom string

	// Duration that certificate is valid for.
	// Default is 365*24*time.Hour.
	ValidFor time.Duration

	// Whether this cert should be its own Certificate Authority
	// Default is false.
	IsCA bool

	// Size of RSA key to generate. Ignored if ECDSACurve is set
	// Default is 2048.
	RSABits int

	// ECDSA curve to use to generate a key. Valid values are P224, P256 (recommended), P384, P521
	// Default is "".
	ECDSACurve string

	// Generate an Ed25519 key
	// Default is false.
	ED25519Key bool
}

GenerateOptions is used to configure the keys.

Jump to

Keyboard shortcuts

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