alias

package module
v0.0.0-...-00b58c6 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2014 License: MIT Imports: 3 Imported by: 0

README

Alias

API Reference

Description

package alias adds alias/redirection to Martini apps using regular expressions to strings. Like mod_rewrite.

Usage

package main

import (
    "github.com/walle/alias"
    "github.com/go-martini/martini"
)

func main() {
    m := martini.Classic()

    alias.Add("^/my/path/to/rewrite", "/my/path", alias.SERVE)
    alias.Add("^/my/path/to/redirect", "/my/path", alias.REDIRECT)
    m.Use(alias.Handler())

    m.Get("/**", func(request *http.Request) string {
        return "Hello " + request.URL.Path
    })

    m.Run()
}

Authors

Documentation

Overview

Package alias adds alias/redirection to Martini apps using regular expressions to strings. Like mod_rewrite.

Index

Constants

View Source
const (
	SERVE = iota
	REDIRECT
)

The different types

Variables

This section is empty.

Functions

func Add

func Add(from, to string, aliasType Type)

Add is used to add a alias. From must be a valid regexp.

func Handler

func Handler() martini.Handler

Handler returns the martini handler that can be added to Use() Starts the alias functionality

func Remove

func Remove(from string)

Remove stops serving a alias

Types

type Alias

type Alias struct {
	// contains filtered or unexported fields
}

Alias defines an alias

type Type

type Type int8

Type determines what kind of alias is used

Jump to

Keyboard shortcuts

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