httpx

package module
v0.0.0-...-3ebd907 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

README

package httpx // import "codeberg.org/lindenii/go-httpx"

Package httpx provides a replacement for the standard library's Redirect
functions for use in Lindenii projects which require strict paths that do not
rely on coalescing // to /.

This is not a drop-in replacement for general use; Redirect panics on relative
paths.

FUNCTIONS

func Redirect(w http.ResponseWriter, r *http.Request, url string, code int)
    Redirect replies to the request with a redirect to url, which must be either
    a absolute or a root-relative path. Any non-ASCII characters in url will be
    percent-encoded, but existing percent encodings will not be changed. Unlike
    the standard library's implementation, double-slashes are not coalesced to
    single slashes, as they are semantically different.

    The provided code should be in the 3xx range and is usually
    [StatusMovedPermanently], [StatusFound] or [StatusSeeOther].

    If the Content-Type header has not been set, Redirect sets it to "text/html;
    charset=utf-8" and writes a small HTML body. Setting the Content-Type header
    to any value, including nil, disables that behavior.

func RedirectHandler(url string, code int) http.Handler

Documentation

Overview

Package httpx provides a replacement for the standard library's Redirect functions for use in Lindenii projects which require strict paths that do not rely on coalescing // to /.

This is not a drop-in replacement for general use; Redirect panics on relative paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Redirect

func Redirect(w http.ResponseWriter, r *http.Request, url string, code int)

Redirect replies to the request with a redirect to url, which must be either a absolute or a root-relative path. Any non-ASCII characters in url will be percent-encoded, but existing percent encodings will not be changed. Unlike the standard library's implementation, double-slashes are not coalesced to single slashes, as they are semantically different.

The provided code should be in the 3xx range and is usually [StatusMovedPermanently], [StatusFound] or [StatusSeeOther].

If the Content-Type header has not been set, Redirect sets it to "text/html; charset=utf-8" and writes a small HTML body. Setting the Content-Type header to any value, including nil, disables that behavior.

func RedirectHandler

func RedirectHandler(url string, code int) http.Handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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