http2https

package module
v0.0.0-...-7ae3b9e Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2025 License: MIT Imports: 3 Imported by: 0

README

go-http2https

Package http2https provides tools to redirect from HTTP to HTTPS, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-http2https

GoDoc

Examples

Here is a simple example:

import "github.com/reiver/go-http2https"

// ...

err := http.ListenAndServe(tcpaddr, http2https.Handler)

Here is an example that provide the http2https http.Hanlder with a function to call to log errors:

import "github.com/reiver/go-http2https"

// ...

func logError(a ...any) {
	fmt.Println(a...)
}

// ...

var handler http.Handler = http2https.HTTPHandler{
	LogError: logError,
}

err := http.ListenAndServe(tcpaddr, handler)

Import

To import package http2https use import code like the following:

import "github.com/reiver/go-http2https"

Installation

To install package http2https do the following:

GOPROXY=direct go get github.com/reiver/go-http2https

Author

Package http2https was written by Charles Iliya Krempeaux

Documentation

Index

Constants

This section is empty.

Variables

Handler is the default http.Handler for this package. Handler does not do any logging.

You can use it rather than creating a new HTTPHandler if you do not need any logging.

If you need logging, then create your own HTTPHandler instead.

Functions

This section is empty.

Types

type HTTPHandler

type HTTPHandler struct {
	LogError func(...any)
}

HTTPHandler deals with redirecting a HTTP request to an HTTPS request.

So, for example, a request to:

http://example.com/apple/banana/cherry

Would get redirected to:

https://example.com/apple/banana/cherry

(Note that the scheme of the URL changed from "http" to "https".)

func (HTTPHandler) ServeHTTP

func (receiver HTTPHandler) ServeHTTP(responsewriter http.ResponseWriter, request *http.Request)

Jump to

Keyboard shortcuts

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