-
Notifications
You must be signed in to change notification settings - Fork 70
/
doc.go
41 lines (40 loc) · 1.27 KB
/
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
32
33
34
35
36
37
38
39
40
41
// Copyright 2018 The xujiajun/gorouter Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// Package gorouter is a simple and fast HTTP router for Go. It is easy to build RESTful APIs and your web framework.
//
// Here is the example:
//
// package main
//
// import (
// "log"
// "net/http"
//
// "github.com/xujiajun/gorouter"
// )
//
// func main() {
// mux := gorouter.New()
// //url parameters match
// mux.GET("/user/{id:[0-9]+}", func(w http.ResponseWriter, r *http.Request) {
// //get one URL parameter
// id := gorouter.GetParam(r, "id")
// //get all URL parameters
// //id := gorouter.GetAllParams(r)
// //fmt.Println(id)
// w.Write([]byte("match user/{id:[0-9]+} ! get id:" + id))
// })
//
// log.Fatal(http.ListenAndServe(":8181", mux))
// }
//
// Here is the syntax:
//
// Syntax Description Example
// :name named parameter /user/:name
// {name:regexp} named with regexp parameter /user/{name:[0-9a-zA-Z]+}
// :id named with regexp parameter /user/:id
//
// And :id is short for {id:[0-9]+}, :name are short for {name:[0-9a-zA-Z_]+}.
package gorouter