1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-05 04:10:54 +00:00
Commit Graph

32 Commits

Author SHA1 Message Date
ysqi
810f6db8d2 fix #1669 write empty body panic error 2016-02-12 11:27:59 +08:00
astaxie
29752e2575 refactor router 2015-12-16 23:11:03 +08:00
astaxie
912abe3272 fix #1388 2015-10-12 21:26:18 +08:00
astaxie
b2048e8653 make router test passed 2015-09-08 22:05:38 +08:00
astaxie
67b36d7c48 make golint happy 2015-09-08 21:41:38 +08:00
astaxie
e619d83990 fix the filter router issues 2015-06-13 12:47:01 +08:00
astaxie
54ba307f7f change this to short name 2014-11-05 22:40:31 +08:00
Bill Davis
b6f789c497 Changes to handle multi filters on execution pt 2014-10-07 16:35:30 -04:00
astaxie
a144769515 update the documents & comments 2014-08-18 16:41:43 +08:00
astaxie
fefd8ddb5b beego: update licence& fix #669 2014-07-03 23:40:21 +08:00
astaxie
0f170a80da update the comments fix #658 2014-06-25 10:39:37 +08:00
astaxie
a5a6a30744 beego: fix the router rule for * 2014-06-23 15:28:53 +08:00
astaxie
085c362ffb beego:fix router expge 2014-06-18 23:32:47 +08:00
astaxie
117904be73 beego:fix the some regexp routes to different func 2014-06-12 23:08:05 +08:00
astaxie
c13141b8bf beego:fix when user defined function equal to HTTP 2014-06-11 22:45:54 +08:00
astaxie
4786fb0948 beego:fix typo NewControllerRegister 2014-06-10 20:12:57 +08:00
astaxie
6c8a7f1382 beego: router change to method Tree 2014-06-09 10:11:37 +08:00
astaxie
e00eab7f49 beego: change to tree 2014-06-08 20:24:07 +08:00
astaxie
8b374d7f90 beego: add benchmark 2014-05-20 18:20:44 +08:00
astaxie
9f01aeed31 beego:remove unused code 2014-05-19 18:52:48 +08:00
astaxie
55ad951bce beego: support more router
//design model
	beego.Get(router, beego.FilterFunc)
	beego.Post(router, beego.FilterFunc)
	beego.Put(router, beego.FilterFunc)
	beego.Head(router, beego.FilterFunc)
	beego.Options(router, beego.FilterFunc)
	beego.Delete(router, beego.FilterFunc)
	beego.Handler(router, http.Handler)

//example

beego.Get("/user", func(ctx *context.Context) {
	ctx.Output.Body([]byte("Get userlist"))
})

beego.Post("/user", func(ctx *context.Context) {
	ctx.Output.Body([]byte("add userlist"))
})

beego.Delete("/user/:id", func(ctx *context.Context) {
	ctx.Output.Body([]byte([]byte(ctx.Input.Param(":id")))
})

import (
    "http"
    "github.com/gorilla/rpc"
    "github.com/gorilla/rpc/json"
)

func init() {
    s := rpc.NewServer()
    s.RegisterCodec(json.NewCodec(), "application/json")
    s.RegisterService(new(HelloService), "")
    beego.Handler("/rpc", s)
}
2014-05-17 02:26:51 +08:00
astaxie
c188cbbcb4 update all files License 2014-05-17 02:26:50 +08:00
astaxie
05e5baaa9f beego:add post test case 2014-05-17 02:26:50 +08:00
astaxie
d57557dc55 add AutoRouterWithPrefix 2014-01-01 17:57:57 +08:00
astaxie
9edf3143e1 fix autorouter params 2013-12-18 10:00:52 +08:00
astaxie
ff1b8588e0 #313 2013-11-26 17:09:23 +08:00
astaxie
b16ef12ac0 fix test 2013-11-26 14:13:23 +08:00
astaxie
43057a2fcb fix #284 2013-11-10 23:26:28 +08:00
astaxie
9446563e5b add util func to get the url fix #282
UrlFor(endpoint string, values ...string) string
2013-11-10 23:05:07 +08:00
astaxie
4ce584c5a6 fix #201 2013-09-22 11:12:37 +08:00
astaxie
9d84969bf6 fix #153
已经支持了任意定义变量的路由形式,具体的使用请参考:

func TestManyRoute(t *testing.T) {

	r, _ := http.NewRequest("GET", "/beego32-12.html", nil)
	w := httptest.NewRecorder()

	handler := NewControllerRegistor()
	handler.Add("/beego:id([0-9]+)-:page([0-9]+).html", &TestController{})
	handler.ServeHTTP(w, r)

	id := r.URL.Query().Get(":id")
	page := r.URL.Query().Get(":page")

	if id != "32" {
		t.Errorf("url param set to [%s]; want [%s]", id, "32")
	}
	if page != "12" {
		t.Errorf("url param set to [%s]; want [%s]", page, "12")
	}
}
2013-09-13 11:22:14 +08:00
astaxie
1ff0a31d3f add router test 2013-09-11 15:49:12 +08:00