1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-16 20:40:54 +00:00
Commit Graph

327 Commits

Author SHA1 Message Date
Simon Rawet
52c4c1fb98 Added MaxMemory limit to CopyBody()
Beego only uses the MaxMemory flag when using go's built in functions
for parsing forms. However the CopyBody() function have no limit an will
coppy anny amount of data into memory using ioutil.ReedAll() on the
request body whitout anny size validation or limit.

This fix wrapps input.Requst.Body in a LimitedReader using the same
memory limit as ParseFormOrMulitForm()
2015-12-16 10:37:21 +01:00
astaxie
2b651fbae2 reuse map in tree.Match 2015-12-11 13:51:01 +08:00
astaxie
80bc372f17 pool.Put 2015-12-11 00:20:17 +08:00
astaxie
f70f338025 use sync.Pool to reuse Context 2015-12-10 21:59:54 +08:00
astaxie
be60f47488 Merge pull request #1455 from nkbai/develop
windows下静态文件映射找不到问题以及 grace init延后
2015-12-09 23:44:45 +08:00
astaxie
d1bba02958 refact beego config 2015-12-09 23:35:04 +08:00
nkbai
ff0762cc19 Merge remote-tracking branch 'upstream/develop' into develop 2015-12-03 15:50:21 +08:00
nkbai
6aaca2eca8 router.go Header 毫无用处
context/output.go 简化一下代码,更清晰
2015-11-26 14:56:39 +08:00
JessonChan
7ef9b3d55b runnable typo fixed 2015-11-10 14:07:26 +08:00
astaxie
fd4630c6dd impove the ResponseWriter. fix #1410 2015-11-04 23:52:42 +08:00
astaxie
912abe3272 fix #1388 2015-10-12 21:26:18 +08:00
JessonChan
caf3714495 revert exceptMethod 2015-09-19 05:41:10 +08:00
JessonChan
983bac986a runFunction camel name 2015-09-18 18:34:07 +08:00
JessonChan
56032c67af runFunction camel name 2015-09-18 18:31:06 +08:00
JessonChan
40cb8e0cf1 use reflect to ensure all methods been except 2015-09-18 18:18:12 +08:00
astaxie
ff5b09fc19 golint context 2015-09-10 15:31:09 +08:00
astaxie
c11740b647 make golint happy router.go 2015-09-08 22:01:13 +08:00
astaxie
67b36d7c48 make golint happy 2015-09-08 21:41:38 +08:00
astaxie
61570ac2f7 make golint happy with controller.go 2015-09-08 10:43:42 +08:00
astaxie
f28a941e26 make golint happy and also make the config readable 2015-09-07 23:19:42 +08:00
陈小玉
506f54a080 Update router.go, add Flush for responseWriter 2015-08-19 15:23:50 +08:00
JessonChan
b26ef5b2e5 typo fixed
registor==>register
innner ==> inner
2015-07-27 08:44:58 +08:00
MrLee.Kun
87e8bcc9be fix FilterHandler crash issue
Filter Handler will crash with error assignment to entry in nil map , params from function Tree.Match() maybe nil.
2015-06-19 11:19:35 +08:00
astaxie
ba1232dfaf filter should be always the same 2015-06-14 18:35:46 +08:00
astaxie
b275d7c6f5 Revert "Revert "fix multiple filters execute issue"" 2015-06-14 01:14:33 +08:00
astaxie
fc11169ee3 Revert "fix multiple filters execute issue" 2015-06-14 01:13:34 +08:00
MrLee.Kun
2af0c569a5 The last filterFunc with returnOnOutput=ture won't be executed
ex:
	beego.InsertFilter("/*", beego.BeforeExec, FilterLoginCheck1,false)
	beego.InsertFilter("/*", beego.BeforeExec, FilterLoginCheck2)

In function  FilterLoginCheck1 , I'll write data via ResponseWriter, and w.started = true
FilterLoginCheck2 won't be executed, it should be.
2015-06-14 01:02:41 +08:00
astaxie
e619d83990 fix the filter router issues 2015-06-13 12:47:01 +08:00
MrLee.Kun
491238ce7d Don't overwrite the params from function ValidRouter
just add new params to context.Input.Params
2015-06-13 01:04:46 +08:00
astaxie
4d70b22f96 Merge pull request #1157 from ziyel/master
Let filter function get more params info from ctx.Input.Params
2015-06-11 14:38:19 +08:00
ziyel
d943d16d52 gofmt 2015-06-10 21:26:04 +08:00
astaxie
364cacf659 record the critical logs in Prod 2015-06-08 22:00:28 +08:00
astaxie
26130a5df6 fix #1073 2015-05-25 09:10:35 +08:00
astaxie
1d8afdc9c9 gofmt -s & go_vet 2015-05-25 09:10:34 +08:00
ziyel
9bb9855153 Let filter function get more params info from ctx.Input.Params 2015-05-18 14:42:18 +08:00
astaxie
3aceaf8838 error support controller 2015-02-26 23:34:43 +08:00
astaxie
3caba06189 Merge pull request #967 from athurg/support_all_type_on_urlfor
Add all type support for UrlFor’s params
2014-12-18 21:14:44 +08:00
Jianbo Feng
e34f8479bb Add all type support for UrlFor’s params 2014-12-17 15:52:48 +08:00
astaxie
9c665afc04 improve the error tips 2014-12-08 14:57:45 +08:00
astaxie
f96245786a fix #912 2014-11-08 15:10:47 +08:00
astaxie
76522d43af simple the session 2014-11-04 19:07:49 +08:00
astaxie
c4d8e4a244 fix #759 2014-11-04 15:29:33 +08:00
astaxie
8d797a4a5e file the static filter 2014-11-03 16:14:40 +08:00
astaxie
fda841208d fix #893 2014-10-30 16:05:48 +08:00
WithGJR
efc14a1e8d fix router bug with more better way 2014-10-16 18:58:12 +08:00
WithGJR
fa1281002e fix router bug: when the request is PUT or DELETE, router can't find the actual route and will throw 404 page to user 2014-10-16 18:26:01 +08:00
Bill Davis
1ba7847913 Changing check from nil to len based on slice 2014-10-08 09:21:34 -04:00
Bill Davis
b6f789c497 Changes to handle multi filters on execution pt 2014-10-07 16:35:30 -04:00
astaxie
aae89576c6 fix #814 2014-10-01 22:31:44 +08:00
astaxie
a907a86476 fix #814 2014-10-01 22:28:49 +08:00
astaxie
3a5de83ec2 beego: support router case sensitive 2014-09-28 22:10:43 +08:00
astaxie
f267ee8a12 fix the same name controller for UrlFor 2014-09-23 00:26:07 +08:00
astaxie
6eee223352 beego: fix the Upper for the _method value 2014-09-03 09:25:34 +08:00
Francois
bc4780091b Proposal for adding a ":" for stack trace printout
Mainly useful for Sublime users with goto anything.
2014-08-30 21:27:21 +02:00
astaxie
7f977a0c8c beego: change the colour 2014-08-20 11:54:25 +08:00
astaxie
aaabeff44f change the route info 2014-08-20 10:59:38 +08:00
astaxie
a144769515 update the documents & comments 2014-08-18 16:41:43 +08:00
astaxie
e07d780dcf update the router info 2014-08-18 15:00:27 +08:00
astaxie
986e91b7d6 beego: update the debug info rules 2014-08-18 14:35:43 +08:00
Francois
75904effd9 Makes more sense to Use Debug instead of Info? 2014-08-15 21:11:16 +02:00
liulixiang1988
118e07158e improve the 'geturl'
If we have a url mapping like this:
`beego.Router(“/test”, &controllers.WeightController{},
"get:GetDetails”)`
when u use `UrlFor(“WeightController.GetDetails”, “foo”, 1, “bar”, 2 `,
it should return `/test?foo=1&bar=2` rather than `/test`.
2014-08-11 22:19:59 +08:00
astaxie
885c0678ff move filter wrong http method 2014-08-04 16:21:34 +08:00
astaxie
474a16a7a0 beego: improve the static file server 2014-08-04 15:31:27 +08:00
astaxie
d17f107fc4 beego: fix #702 auto render 2014-07-18 13:29:54 +08:00
astaxie
19c3a5b41c beego: improve the router debug infomation 2014-07-09 09:38:36 +08:00
Christoph Portmann
3bb4d6f013 beego/context: Fix ignored Header in case SetStatus has been called before 2014-07-08 23:24:47 +03:00
astaxie
fefd8ddb5b beego: update licence& fix #669 2014-07-03 23:40:21 +08:00
astaxie
14dee37a21 beego: autorouter params 2014-07-01 16:55:23 +08:00
astaxie
34936dde35 Merge branch 'master' into develop 2014-06-30 23:50:45 +08:00
ljyf5593
ac96c2b15e beego: fix #657
路由地址不区分大小写问题
2014-06-27 11:06:29 +08:00
astaxie
0f170a80da update the comments fix #658 2014-06-25 10:39:37 +08:00
astaxie
af4f153830 beego: update the router rule for *
* not match the empty route
2014-06-21 11:44:24 +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
3db9633ebd remove websocket logic because not support handler 2014-06-11 11:12:17 +08:00
astaxie
6809c97611 beego: improve performance 2014-06-11 01:11:32 +08:00
astaxie
4786fb0948 beego:fix typo NewControllerRegister 2014-06-10 20:12:57 +08:00
astaxie
107a7a21c0 beego: dev mode print request router & pattern 2014-06-10 18:09:07 +08:00
astaxie
f7b01aab13 beego: modify the filter sequence 2014-06-10 11:02:41 +08:00
astaxie
2570f075d9 beego:change ControllerComments exported 2014-06-09 17:46:13 +08:00
astaxie
21cb8ea4a3 beego:AST code 2014-06-09 17:33:04 +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
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