strip

package
v0.0.0-...-8ce6181 Latest Latest
Warning

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

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

README

strip

API Reference

Description

packcage strip modifies the URL before the requests go into the other handlers.

Currently the main function in package strip is strip.Prefix which provides the save functionality as http.StripPrefix and can be used in martini instance and request context level.

With strip.Prefix martini instances can be installed upon each other, and so does some other web framework like web.go.

Usage

package main

import (
	"github.com/codegangsta/martini-contrib/strip"
	"github.com/codegangsta/martini"
)

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

	m2 := martini.Classic()
	m2.Get("/", func() string {
		return "Hello World from 2nd martini"
	})

	m2.Get("/foo", func() string {
		return "Hello foo"
	})

	m.Get("/", func() string {
		return "Hello World from 1st martini"
	})
	m.Get("/2ndMartini/.*", strip.Prefix("/2ndMartini"), m2.ServeHTTP)

	m.Run()
}

But the example above can only translate the same HTTP method from m.Get to m2.Get, in order to transfer all kinds request such as Post,Delete, etc to m2, martini has to provide a method Any to match any HTTP method to a certain URL pattern.

Authors

Documentation

Overview

packcage strip provides the same functionality as http.StripPrefix and can be used in martini instance level and request context level.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prefix

func Prefix(prefix string) martini.Handler

strip Prefix for every incoming http request

Types

This section is empty.

Jump to

Keyboard shortcuts

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