• Stars
    star
    1,413
  • Rank 32,004 (Top 0.7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 12 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

pat (formerly pat.go) - A Sinatra style pattern muxer for Go's net/http library

GoDoc

INSTALL

$ go get github.com/bmizerany/pat

USE

package main

import (
	"io"
	"net/http"
	"github.com/bmizerany/pat"
	"log"
)

// hello world, the web server
func HelloServer(w http.ResponseWriter, req *http.Request) {
	io.WriteString(w, "hello, "+req.URL.Query().Get(":name")+"!\n")
}

func main() {
	m := pat.New()
	m.Get("/hello/:name", http.HandlerFunc(HelloServer))

	// Register this pat with the default serve mux so that other packages
	// may also be exported. (i.e. /debug/pprof/*)
	http.Handle("/", m)
	err := http.ListenAndServe(":12345", nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}

It's that simple.

For more information, see: http://godoc.org/github.com/bmizerany/pat

CONTRIBUTORS

  • Alexis Svinartchouk (@zvin)
  • Blake Mizerany (@bmizerany)
  • Brian Ketelsen (@bketelsen)
  • Bryan Matsuo (@bmatsuo)
  • Caleb Spare (@cespare)
  • Evan Shaw (@edsrzf)
  • Gary Burd (@garyburd)
  • George Rogers (@georgerogers42)
  • Keith Rarick (@kr)
  • Matt Williams (@mattyw)
  • Mike Stipicevic (@wickedchicken)
  • Nick Saika (@nesv)
  • Timothy Cyrus (@tcyrus)
  • binqin (@binku87)

LICENSE

Copyright (C) 2012 by Keith Rarick, Blake Mizerany

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

roundup

eliminate bugs and weeds from shell scripts
Shell
424
star
2

noeqd

A fault-tolerant network service for meaningful GUID generation
Go
340
star
3

sinatra-activerecord

Extends Sinatra with ActiveRecord helper methods and Rake tasks (now maintained by @holman).
Ruby
194
star
4

perks

Effective Computation of Things
Go
182
star
5

pq

Go
179
star
6

assert

Asserts to Go testing
Go
142
star
7

sinatra-dj

a simple piglatin app to show off sinatra + DJ
Ruby
81
star
8

aws4

A Go package for AWS Signature version 4
Go
73
star
9

sinatra-redis

A light extension for using redis with Sinatra
Ruby
60
star
10

lizzy

An DSL for creating AMQP agents; quickly.
Ruby
53
star
11

vendor

Vendor copies go dependencies to ./vendor
Go
52
star
12

onis

runtime object introspection for ruby process
Ruby
44
star
13

pq.go

Go
39
star
14

sinatra-captcha

Quick, simple, fast captcha for Sinatra
Ruby
37
star
15

mc

Binary Memcached client for Go with SASL support
Go
34
star
16

heroku-sinatra-app

Ruby
32
star
17

aws

An old simple AWS client in Go (use bmizerany/aws4 for more up to date aws usage).
Go
26
star
18

sinatra-any

Granular before filters for sinatra
Ruby
24
star
19

redis-erl

Minimilast Redis Client for Erlang
Erlang
21
star
20

swirl

API version agnostic EC2 client
Ruby
20
star
21

beldam

clean, easy, ec2 wrapper
Ruby
14
star
22

logplex

Go
14
star
23

swirl-node

JavaScript
13
star
24

em-swirl

An evented Ruby EC2 driver for EventMachine
Ruby
12
star
25

recho

echo(1) in ruby
Ruby
11
star
26

nodefinder

Erlang node finders
11
star
27

noeq.go

Go client for noeqd
Go
10
star
28

pqx

Go
9
star
29

sinatra-slaushed

redis powered authentication for Sinatra
Ruby
9
star
30

frylock

Ruby + CLI + DSL = Command line apps made easy! (Not ready yet)
Ruby
8
star
31

supermemo

SM2 application
Ruby
7
star
32

inotify-ffi

Ruby
7
star
33

guns

It has two pipes; got tickets to the show?
Ruby
7
star
34

noeq

A command line client for noeqd
Go
6
star
35

lpx

Logplex framing parser
Go
6
star
36

lively-docs

Escape the hell of `rake rdoc` .. edit .. `rake rdoc` .. edit .. etc.
5
star
37

pat.go

Now at bmizerany/pat
Go
5
star
38

WAck

Ack! for the web.
Ruby
5
star
39

heroku-docs

Documentation for Heroku, in the form of a Sinatra app serving markdown text files.
Ruby
5
star
40

jabberlang

Erlang jabber client
5
star
41

sinatra-template-vendor

Ruby
4
star
42

domainy

for getting the base of a domain
Ruby
4
star
43

RedisPl

Redis Perl Bindings (from svn://svn.rot13.org/Redis/)
Perl
3
star
44

lameetup

Ruby
3
star
45

sinatra-sassacache

Extends Sinatra with a route to compile and cache Sass templates
3
star
46

test

a test for work
3
star
47

attrubates

Arrtubates sets meta on meta for objects and adds additional rendering helpers for ActionController::Base in Rails.
Ruby
3
star
48

lorem-me

Hacker's Lorem Ipsum Genereator with Gists.
Ruby
3
star
49

sinatra-ext-pres

Sinatra Extensions Presentation
Ruby
2
star
50

schemafinder

2
star
51

fido

he fetches
Shell
2
star
52

hk

Fast Heroku client
Go
2
star
53

Elephant

An Adium Plugin for keeping realtime backup/full-text search of all chats
Objective-C
2
star
54

pages

Go
2
star
55

aws.go

Go
2
star
56

doozer-bench

bechmark the doozerz
Go
1
star
57

muni

Quick muni notifications for us SF dwellers
1
star
58

bang

banger
Ruby
1
star
59

mc.go

Go
1
star
60

onis-web

1
star
61

vips

Go
1
star
62

fsh

Fuck syntax highlighting. The correct default for the Atom (atom.io) editor.
CSS
1
star
63

theherms

example - don't look
1
star