slash

package
Version: v2.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2018 License: MIT Imports: 3 Imported by: 5

Documentation

Overview

Package slash provides a trailing slash remover handler for the ozzo routing package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Remover

func Remover(status int) routing.Handler

Remover returns a handler that removes the trailing slash (if any) from the requested URL. The handler will redirect the browser to the new URL without the trailing slash. The status parameter should be either http.StatusMovedPermanently (301) or http.StatusFound (302), which is to be used for redirecting GET requests. For other requests, the status code will be http.StatusTemporaryRedirect (307). If the original URL has no trailing slash, the handler will do nothing. For example,

import (
    "net/http"
    "github.com/go-ozzo/ozzo-routing"
    "github.com/go-ozzo/ozzo-routing/slash"
)

r := routing.New()
r.Use(slash.Remover(http.StatusMovedPermanently))

Note that Remover relies on HTTP redirection to remove the trailing slashes. If you do not want redirection, please set `Router.IgnoreTrailingSlash` to be true without using Remover.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

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