-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc.go
31 lines (31 loc) · 914 Bytes
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package route provides URL router allowing usage of regexp in URL paths.
//
// package main
//
// import (
// "github.com/taironas/route"
// "net/http"
// "fmt"
// )
//
// func main() {
// r := new(route.Router)
// r.HandleFunc("/users", usersHandler)
// r.HandleFunc("/users/:id", userHandler)
// r.HandleFunc("/users/:id/friends/:username", friendHandler)
//
// http.ListenAndServe(":8080", r)
// }
//
// func usersHandler(w http.ResponseWriter, r *http.Request) {
// fmt.Fprintf(w, "Welcome to users handler!")
// }
//
// func userHandler(w http.ResponseWriter, r *http.Request) {
// fmt.Fprintf(w, "Welcome to user handler, user id = %s!", route.Context.Get(r, "id"))
// }
//
// func friendHandler(w http.ResponseWriter, r *http.Request) {
// fmt.Fprintf(w, "Welcome to friend handler, friend username = %s!", route.Context.Get(r, "username"))
// }
package route