1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-30 00:31:29 +00:00
Commit Graph

294 Commits

Author SHA1 Message Date
astaxie
e00eab7f49 beego: change to tree 2014-06-08 20:24:07 +08:00
astaxie
5dee6b7d19 beego: fix the namespace cond 2014-05-28 10:23:31 +08:00
astaxie
f6c7a6bd32 beego: improve the admin router print 2014-05-27 17:27:22 +08:00
astaxie
3f7e91e6a4 beego:fix *.* router bug 2014-05-26 10:15:56 +08:00
astaxie
0d17d974cd beego: update namespace 2014-05-23 15:56:25 +08:00
astaxie
17104c25a2 beego: Refactoring Filter & add comments 2014-05-20 18:47:41 +08:00
astaxie
9f01aeed31 beego:remove unused code 2014-05-19 18:52:48 +08:00
astaxie
c5c806b58e beego: XSRF support Controller level fix #610
default value is true when you Enable Global XSRF, also can control in
the prepare function to change the value.
2014-05-17 02:26:51 +08:00
astaxie
e657dcfd5f beego: support namespace
ns := beego.NewNamespace("/v1/api/")
ns.Cond(func(ctx *context.Context)bool{
	    if ctx.Input.Domain() == "www.beego.me" {
	    	return true
	    }
	    return false
	})
.Filter("before", Authenticate)
.Router("/order",	&admin.OrderController{})
.Get("/version",func (ctx *context.Context) {
	ctx.Output.Body([]byte("1.0.0"))
})
.Post("/login",func (ctx *context.Context) {
	if ctx.Query("username") == "admin" && ctx.Query("username") ==
"password" {

	}
})
.Namespace(
	NewNamespace("/shop").
		Get("/order/:id", func(ctx *context.Context) {
		ctx.Output.Body([]byte(ctx.Input.Param(":id")))
	}),
)
2014-05-17 02:26:51 +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
3b9a404138 beego: support other analisys & fix typo 2014-05-17 02:26:50 +08:00
astaxie
c188cbbcb4 update all files License 2014-05-17 02:26:50 +08:00
astaxie
4245521660 fix #576 2014-05-17 02:26:50 +08:00
astaxie
aa68ffecec beego: support not-empty value in router fix #555 2014-05-17 02:26:50 +08:00
astaxie
3255a43568 beego: move staticServer to New file 2014-04-06 00:18:21 +08:00
asta.xie
9c959fba4d fix string 2014-03-29 14:59:55 +08:00
asta.xie
5588bfc35e support filter to get router. get runController & runMethod 2014-03-29 14:55:34 +08:00
astaxie
5d392b76c7 Merge pull request #531 from unphp/develop
Update router.go
2014-03-14 10:08:47 +08:00
asta.xie
769f7c751b fix static file route 2014-03-12 21:06:20 +08:00
asta.xie
624f6258ee fix read / 2014-03-12 18:29:45 +08:00
unphp
43c977ab62 Update router.go
To append a slice's value into "exceptMethod", for controller's methods shouldn't reflect to AutoRouter
2014-03-12 17:20:53 +08:00
asta.xie
6c92ca2a16 fix bug for static file like /static /static_js /static_css 2014-03-12 17:03:34 +08:00
asta.xie
f7430a2ce1 enhance the static file path. If user foget / path.Join will auto fix it. 2014-03-12 15:56:05 +08:00
asta.xie
04a19685ed enhance the static file path. If user foget / path.Join will auto fix it. 2014-02-26 14:44:41 +08:00
slene
6e9ba0ea7f fix SessionRegenerateID should release old SessionStore and release new SessionStore in router.go 2014-01-11 17:01:33 +08:00
astaxie
31bdb793cf make fix 2014-01-05 15:21:50 +08:00
astaxie
d57557dc55 add AutoRouterWithPrefix 2014-01-01 17:57:57 +08:00
astaxie
1e57587fe9 support Hijacker #428 2013-12-31 20:47:48 +08:00
astaxie
a1e29b0b75 Merge pull request #422 from pengfei-xue/devel
simplify condition test for trailing /
2013-12-30 04:58:50 -08:00
astaxie
984b0cbf31 1. :all param default expr change from (.+) to (.*)
2. add hookfunc to support appstart hook
2013-12-30 15:06:51 +08:00
Pengfei Xue
3a08eec1f9 simplify condition test for trailing / 2013-12-30 11:29:35 +08:00
astaxie
95dc670eb4 fix #416 2013-12-28 23:06:20 +08:00
astaxie
7a3d05ebf3 when pattern is /admin while the url is /admin/ should return 200. fix #416 2013-12-28 23:04:45 +08:00
astaxie
0b659961ba clearly the router, If user set the third params, will not follow the RESTful method 2013-12-24 15:27:00 +08:00
傅小黑
ff18ae2562 add api comments in file memzipfile.go,reload.go,router.go,template.go and templatefunc.go, fix spelling error GetInitListner as GetInitListener. 2013-12-21 13:19:24 +08:00
astaxie
57781d1001 when panic show the request url 2013-12-21 01:20:35 +08:00
astaxie
419c3fc772 remove contextBuffer fix #396 2013-12-21 00:34:59 +08:00
astaxie
3f0e55de56 reverse pull request 397, it not a bug. Just should this way 2013-12-20 13:20:09 +08:00
Pengfei Xue
00020139c5 fix routing bug 2013-12-20 11:38:29 +08:00
astaxie
e481671814 _method also must support user defined router 2013-12-19 13:07:43 +08:00
astaxie
53b2a29b44 when method is POST then to parse form 2013-12-19 12:50:47 +08:00
astaxie
cb49be7815 fix router Put and Delete method when post method with _method 2013-12-19 12:47:54 +08:00
astaxie
de0113ae6a add comments & change channel from 100 to 1000 2013-12-19 00:43:29 +08:00
astaxie
7242bc862e improve main login performance 2013-12-18 23:48:43 +08:00
astaxie
b346617dc1 context.output now need reponsewriter 2013-12-18 22:35:52 +08:00
astaxie
b8ed790858 recycling memory buffer in context 2013-12-18 22:33:21 +08:00
astaxie
48cefc6767 improve performance change reflect to interface 2013-12-18 21:32:25 +08:00
astaxie
e01fbd497c when call abort show the err:http: multiple response.WriteHeader calls 2013-12-18 20:53:23 +08:00
astaxie
9edf3143e1 fix autorouter params 2013-12-18 10:00:52 +08:00
slene
00065f2b08 fix mime bug !! 2013-12-18 00:05:04 +08:00
astaxie
c3bc2bedc0 add methodName to fix #380 & arrangement the router 2013-12-17 11:19:18 +08:00
astaxie
7b27b7fed0 change SopRun to a variable 2013-12-17 08:53:20 +08:00
astaxie
b9fdbdf7b5 use StopRun to terminate the execution 2013-12-16 23:22:15 +08:00
astaxie
436f9a7468 move session init before static 2013-12-16 22:56:35 +08:00
astaxie
f8708d01bf update abort & error show & sessionRelease in defer 2013-12-16 22:54:29 +08:00
astaxie
7fd18ba639 modify in the autorouter's Render #377 2013-12-16 11:46:54 +08:00
vadimi
31f862c526 Panic template execution errors to show error pages accordingly 2013-12-15 13:17:27 -05:00
Pengfei Xue
72af5ce582 add do_filter func to reduce duplicated code 2013-12-15 21:02:28 +08:00
Francois
9995168f9a Update router.go 2013-12-14 20:35:57 +02:00
astaxie
495033b977 fix #366 2013-12-13 21:25:32 +08:00
astaxie
19119e99f7 move utils to utils libs & func move to templatefunc 2013-12-12 22:25:08 +08:00
vadimi
d79977977d Improve unhandled error handling in prod mode 2013-12-06 00:47:34 -05:00
astaxie
7196d6ede3 Revert "Improve unhandled error handling in prod mode"
This reverts commit c2079276eb.
2013-12-06 13:37:36 +08:00
vadimi
c2079276eb Improve unhandled error handling in prod mode 2013-12-05 20:57:02 -05:00
vadimi
12a37f71be Fixed some typos 2013-12-04 22:27:29 -05:00
astaxie
3c91360d72 dictinct system pkg and third pkg 2013-12-03 21:37:39 +08:00
astaxie
54fb49ed95 fix #315 2013-11-26 16:47:50 +08:00
astaxie
f9e732b5ce fix param to params 2013-11-26 11:16:22 +08:00
astaxie
7b405e9af7 fix type 2013-11-26 11:05:12 +08:00
Pengfei Xue
76c0636125 beego.Context.Abort return immediately
* add common 4XX/5XX HTTP exceptions
2013-11-26 08:46:46 +08:00
knightmare
b4fb657efd eliminated improper comments 2013-11-25 16:15:48 +08:00
knightmare
8c3b936c60 replace filterPos to pos 2013-11-25 16:04:02 +08:00
knightmare
47fc32ba47 add func InsertFilter(pattern string, pos int, filter FilterFunc) *App to replace AddFilter
pos can be const:
    BeforeRouter = iota
    AfterStatic
    BeforeExec
    AfterExec
    FinishRouter
2013-11-25 15:59:40 +08:00
astaxie
54185df46e change admin to toolbox & support task 2013-11-20 21:18:00 +08:00
astaxie
ea513002c5 admin filter finish to all router include static file
so if your web is need auth or release the resoure you can writer the
finish filter
2013-11-15 21:51:36 +08:00
astaxie
097bcb3b5b Improve monitoring management module 2013-11-15 18:08:53 +08:00
astaxie
18335194bc fix runrouter is nil 2013-11-13 21:37:17 +08:00
astaxie
6c13bdde25 support profile & statistics in another port 2013-11-13 21:11:09 +08:00
astaxie
2f75445520 when runmode is dev it will show warning ingo
if have a attack url, the info is
2013-11-10 23:42:07 +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
2a81595c3e fix #280 2013-11-08 17:23:56 +08:00
astaxie
9e4d886a6c filter http method fix #279 2013-11-07 22:10:54 +08:00
astaxie
3ac5eec301 fix #253 2013-10-28 22:38:50 +08:00
astaxie
35a136bcee fix #232 2013-09-29 15:38:28 +08:00
astaxie
aaf1490ff5 fix router 2013-09-28 23:37:05 +08:00
astaxie
a62ed10ab3 add supoort AppController
http://play.golang.org/p/MZptHZeYUx
2013-09-28 23:30:36 +08:00
astaxie
8a37c30f35 fix #226 2013-09-28 21:45:52 +08:00
astaxie
797bd98269 fix #210 2013-09-22 14:32:18 +08:00
astaxie
4a3d32dc1f support auto get session from input fix #211 2013-09-22 11:43:22 +08:00
astaxie
048be29fcd add w.started fix #208 2013-09-22 11:17:18 +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
9f6b803a10 update middleware & beego's error 2013-09-11 17:00:39 +08:00
astaxie
e7f08946d1 improve the performance 2013-09-11 15:16:09 +08:00
astaxie
a88750d2b3 support websocket 2013-09-10 17:56:06 +08:00
astaxie
bd61dd9ffc change a log about new version 2013-09-10 00:00:18 +08:00
astaxie
50f3bd5835 add filter after 2013-08-12 00:14:42 +08:00
astaxie
1f3ae3d682 Improve performance 2013-08-11 23:27:53 +08:00
astaxie
bbef213155 fix #144 2013-08-10 21:44:27 +08:00
astaxie
f9a31ea00a EnableXSRF 2013-08-06 23:21:52 +08:00
astaxie
fd3c8834da autorouter when /admin 301 to /admin/ 2013-08-04 23:13:29 +08:00
astaxie
3d481178d7 improve router 2013-08-04 23:06:48 +08:00
astaxie
a997ca746f fix router's /path/ 2013-07-30 22:38:01 +08:00
astaxie
572e281566 fix router's bug 2013-07-30 22:33:36 +08:00
astaxie
8674b81b3a fix router & tpl tolower 2013-07-30 22:17:16 +08:00
astaxie
0e748c6871 parse url to params
/object/login/2009/07/11
parse to ObjectController  Login function
params:map[0:2009 1:07 2:11]
2013-07-27 10:55:10 +08:00
astaxie
f7e7fab6f2 support autorouter 2013-07-27 10:25:14 +08:00
astaxie
ab08aa9c9e MethodByName 2013-07-25 16:08:18 +08:00
astaxie
7c610ee7c9 fix reflect find methodByName 2013-07-25 16:00:42 +08:00
astaxie
e88c2be013 update docs & update beego's version 2013-07-25 15:37:38 +08:00
astaxie
d5ddd0a9dd support user define function
+//Add("/user",&UserController{})
+//Add("/api/list",&RestController{},"*:ListFood")
+//Add("/api/create",&RestController{},"post:CreateFood")
+//Add("/api/update",&RestController{},"put:UpdateFood")
+//Add("/api/delete",&RestController{},"delete:DeleteFood")
+//Add("/api",&RestController{},"get,post:ApiFunc")
+//Add("/simple",&SimpleController{},"get:GetFunc;post:PostFunc")
2013-07-25 15:17:09 +08:00
Unknown
7f5dd13422 Fixed bug: error page cannot show correct corresponding status code 2013-07-18 14:42:45 +08:00
astaxie
7bfb4126d7 support copy requestbody 2013-07-08 23:12:31 +08:00
astaxie
ee9223b1b9 fix #18
func (this *MainController) Get() {
this.GoToFunc("Test")
}

func (this *MainController) Test() {
this.Ctx.WriteString("testtest")
}
2013-07-08 17:35:09 +08:00
astaxie
11977f4f77 fix #90 2013-07-07 17:58:50 +08:00
astaxie
461eac46b9 fix #89 2013-07-07 17:45:39 +08:00
astaxie
75af664511 change r.ParseMultipartForm position 2013-07-04 23:41:35 +08:00
astaxie
9e41d93184 delete strcut map
I think if user should set field in controller, there's no need to have
thie feature
2013-06-25 16:44:53 +08:00
astaxie
512ddf8a70 fix small bug for not return 2013-06-24 23:56:53 +08:00
astaxie
c5a23d5cde fix #81 2013-06-24 23:24:33 +08:00
astaxie
3475685233 add Server info 2013-06-20 15:49:43 +08:00
Lunny Xiao
f20ad0916f bug fix 2013-06-04 19:45:48 +08:00
Lunny Xiao
65041aae71 remove nonuse parseForm and change the StructMap's params 2013-05-31 14:07:06 +08:00
Lunny Xiao
8b7cba037e add url params -> controller's member feature 2013-05-28 16:43:23 +08:00
Lunny Xiao
2dee30183d add structmap function for controller 2013-05-28 13:58:42 +08:00
astaxie
719f94b35f fix findrouter & template mix 2013-05-13 16:31:23 +08:00
astaxie
d6dd84d535 favicon.ico default deal with static files 2013-05-08 16:35:29 +08:00
astaxie
ce77c273cf add Destructor func 2013-05-08 13:56:48 +08:00
astaxie
a851641f48 update params 2013-05-08 13:00:35 +08:00
astaxie
1e7c1a265e fix #16 2013-05-07 00:17:25 +08:00
astaxie
7b6a571f87 fix build 2013-04-27 22:48:20 +08:00
astaxie
cf82cfeea2 #45 add support post+_method 2013-04-27 22:47:48 +08:00
astaxie
f4a645027e add error show page 2013-04-11 14:35:43 +08:00
astaxie
f00ac81008 word change to string 2013-04-10 10:20:23 +08:00
astaxie
465ed4b72f fix router's bug 2013-04-09 23:51:19 +08:00
astaxie
2f02653b7d add GetFIle & enhance router 2013-04-09 23:33:48 +08:00
astaxie
4353c98fd0 fix router's bug when requestpath only have one character 2013-04-08 21:26:38 +08:00
astaxie
3ad639e739 support websocket #20
add example chat
2013-04-08 00:28:32 +08:00
astaxie
4d4096c7e4 fix previer bug 2012-12-19 16:41:39 +08:00
astaxie
3f076f4ca0 fix router like /admin/index/ should equal to /admin/index 2012-12-19 16:38:25 +08:00
astaxie
5ce009a2dc fix bug 2012-12-19 11:26:10 +08:00
astaxie
8a99591298 fix bug 2012-12-18 15:18:48 +08:00
xiemengjun
f593c1f3fd init framwork 2012-12-15 23:53:19 +08:00