1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-30 08:46:41 +02:00
Commit Graph

208 Commits

Author SHA1 Message Date
178inaba
269dfcc9dd
Set maxParam with SetParamNames (#1535)
* Set maxParam with SetParamNames

Fixes #1492

* Revert go.mod
2020-03-30 12:28:07 -07:00
lukesolo
84b8aaf24f
Fix panic in FormFile if file not found (#1515) 2020-02-29 07:46:25 -08:00
Shinichi TAMURA
7c5af01350
Safer/trustable extraction of real ip from request (#1478)
* Safer/trustable extraction of real ip from request

* Fix x-real-ip handling on proxy

* fix docs

* fix default check
2020-02-24 08:29:34 -08:00
J. David Lowe
8d7f05e533 round-trip paramValues without exploding (#1463) 2020-01-23 18:32:17 -08:00
Alex Besogonov
5c7c87d09e Add ability to set the logger on echo.Context (#1377)
This change allows middleware to replace the logger on the echo.Context
with a customized per-request logger with additional fields. The logger
is reset to default on every Reset() call.
2019-11-11 12:34:13 -08:00
Argishti Rostamian
754b44989f Close file descriptor returned by request.FormFile (#1411) 2019-10-24 11:52:14 -07:00
Mark Smith
ee6618e831 reset p.values to echo.maxParam (#1429)
* reset p.values to echo.maxParam
* Update context.go

How about just reset the values?
2019-10-24 10:48:56 -07:00
Jesse Szwedko
608cebbaae Assign new ResponseWriter after calling http.HandlerFunc (#1341)
Otherwise, the `http.ResponseWriter` passed to `next()` within the
middleware is unused. This precludes middlewares from wrapping the
http.ResponseWriter to do things like record the status code.
2019-08-07 11:10:18 -07:00
Noam Y. Tenne
fbb72869b3 Fix for #1334 (#1335)
* echo.context.cjson should encode the JSON before writing the status code #1334 :

`response.Write` automatically sets status to `200` if a response code wasn't committed yet. This is convenient, but it ignores the fact that `response.Status` is a public field that may be set separately/before `response.Write` has been called
A `response.Status` is by default `0`, or `200` if the response was reset, so `response.Write` should fallback to `200` only if a code wasn't set yet.

* echo.context.cjson should encode the JSON before writing the status code #1334 :

Writing the response code before encoding the payload is prone to error.
If JSON encoding fails, the response code is already committed, the server is able to only modify the response body to reflect the error and the user receives an awkward response where the status is successful but the body reports an error.
Instead - set the desired code on `c.response.Status`. If writing eventually takes place, the desired code is committed. If an error occurs, the server can still change the response.
2019-05-23 22:13:57 -07:00
Hemachandar
775b2eefec Refactor DefaultProxyConfig Skipper & WebSocket Check in Context (#1297)
* refactor: default to DefaultProxyConfig.Skipper if not provided

* refactor: use strings library for websocket check
2019-03-02 10:43:23 -08:00
Andrei Avram
3d73323154 Use concurrency safe context by default. (#1158) 2019-02-12 10:56:26 -08:00
Vishal Rana
7867fce6ce Changes related to #1199
Signed-off-by: Vishal Rana <vr@labstack.com>
2019-01-14 10:56:17 -08:00
Evgeniy Kulikov
62145fad3e [extend #1191] Unnecessary alloc for XML, JSON, JSONP (#1199)
* [extend #1191] Unnecessary alloc for XML, JSON, JSONP

* add legacy (JSON/JSONP/XML)Blob tests

* fix namings

* fix `jsonPBlob` allocs

* fix review comments (thx @alexaandru)

* fix review comments (thx @alexaandru)
add benchmarks
2019-01-14 10:12:22 -08:00
Emir Ribić
a2d4cb9c7a Simplify REALIP method (#1193)
* Simplify REALIP method

* Remove alloc
2018-09-19 10:18:50 -07:00
Vishal Rana
a5d81b8d4a Updated deps, removed json-iterator, fixed #1087, fixed #1086
Signed-off-by: Vishal Rana <vr@labstack.com>
2018-03-16 10:00:59 -07:00
Vishal Rana
f4dde46fed Fixed build
Signed-off-by: Vishal Rana <vr@labstack.com>
2018-03-14 22:59:15 -07:00
Vishal Rana
003b0adaa5 Enhanced write content type
Signed-off-by: Vishal Rana <vr@labstack.com>
2018-03-14 22:51:06 -07:00
Vishal Rana
20ac716d4c Using json-iterator
Signed-off-by: Vishal Rana <vr@labstack.com>
2018-03-14 20:38:46 -07:00
Romain Gros
fb30777387 Return error of context.File in c.contentDisposition
context.Attachment and context.Inline use context.contentDisposition under the hood.
However, context.contentDisposition does not forward the error of context.File, leading to response 200 OK even when the file does not exist.
This commit forward the return value of context.File to context.contentDisposition to prevent that.
2018-03-06 10:50:53 -08:00
Vishal Rana
ec048ea523 Fixed #1052, dropped param alias feature
Signed-off-by: Vishal Rana <vr@labstack.com>
2018-01-30 19:02:29 -08:00
goofle
4df355113b Wrap Content-Disposition filename with quotes (#996) 2017-08-24 08:35:50 -07:00
Rene Jochum
0769b34b52 Use the NotFoundHandler when a file haven't been found. (#966)
This is especialy usefull when you use e.Static("/", "static") and you
want a notfoundhandler that serves your index.html like this:

echo.NotFoundHandler = func(c2 echo.Context) error {
	index := filepath.Join(c.config.StaticDir, c.config.Index)
	_, err := os.Open(index)
	if err != nil {
		return echo.ErrNotFound
	}
	return c2.File(path.Join(c.config.StaticDir, c.config.Index))
}

Another usecase with the Handler above is HTML5 SPF applications.

One caveat, you need to make sure that your NotFoundHandler doesn't
produce loops.

Signed-off-by: Rene Jochum <rene@jochums.at>
2017-07-19 11:29:41 -07:00
Vishal Rana
bd96cc3c15 Fixed #947
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-06-06 14:59:35 -07:00
Vishal Rana
c3887ebb13 Added Context#IsWebSocket(), proxy fix header
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-06-04 10:39:08 -07:00
TossPig
353a2f8b78 Get The HeaderXForwardedProto (#941)
* Get The HeaderXForwardedProto

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto

* add HeaderXForwardedSsl

* Get The HeaderXForwardedSsl
2017-06-04 09:41:17 -07:00
Vishal Rana
533d7a8dc1 Closes #918, docs updated for testing handler
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-04-29 11:02:57 -07:00
Sub
0dfcb31d9e Automatically use JSONPretty/XMLPretty if '?pretty' in querystring (#916)
* Automatically use JSONPretty/XMLPretty if '?pretty' in querystring

* Update unit test cases

* Simplify code according comments

* Update guide for pretty json/xml
2017-04-27 21:41:46 -07:00
Vishal Rana
ac0a38d995 Fixed Context#RealIP() to fetch the first IP
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-04-20 12:05:09 -07:00
Vishal Rana
d5bff83dc3 Using *context instead of Context in Router#Find()
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-04-10 13:10:31 -07:00
Ole Bulbuk
f0e3f950cf Tested and fixed bug with reused context (path parameters). 2017-03-30 12:05:24 +02:00
Vishal Rana
22012e0e9d Fixed #833
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-03-26 20:15:48 -07:00
Vishal Rana
477d8dc708 Fixed #839
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-03-15 11:38:43 -07:00
Vishal Rana
c7c4395fbd Fixed #794
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-01-31 13:55:39 -08:00
Vishal Rana
54fb1015c1 Pretty print in debug mode
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-01-04 12:00:49 -08:00
Ted Kornish
eb7ebca112 Correct comment for Context.Response (#793) 2017-01-01 22:02:14 -08:00
Vishal Rana
294601a6ba docs: add guide/response
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-12-13 20:26:25 -08:00
Vishal Rana
01334bc7b2 enabled validator, updated docs, fixed #298, fixed #438, fixed #305
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-12-12 17:19:41 -08:00
Vishal Rana
20954afd66 fixed json, xml pretty print
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-12-09 11:13:55 -08:00
Vishal Rana
133f7acf21 fixed #762
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-12-09 10:24:14 -08:00
Vishal Rana
1f0bae394a Gannett digital master allow html buffers (#765)
* Since some templating engines final result is a buffer, we've been casting them to strings, which is a bit unnecessary considering under the hood Echo supports this.

* Since some templating engines final result is a buffer, we've been casting them to strings, which is a bit unnecessary considering under the hood Echo supports this.

* Update context.go

* Update context_test.go

* Update context_test.go

* Utilize same design pattern for HTMLBlob as JSONBlob

* Streamlined a few more methods

* more  consistent

Signed-off-by: Vishal Rana <vr@labstack.com>
2016-12-06 18:57:06 -08:00
Vishal Rana
fd9508ca39 param alias, context#param
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-11-17 18:42:00 -08:00
Vishal Rana
8aa0e56e50 cleaner Context#Param
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-11-17 08:00:30 -08:00
Vishal Rana
c5a3575d4c updated migration guide
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-11-14 22:54:09 -08:00
Vishal Rana
7bd314557b fixed #694
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-27 07:35:41 -07:00
Vishal Rana
a739d9a0d9 - Removed Context#ServeContent
- Refactored Context#Attachment, Context#Inline,
  Context#ContentTypeByExtension

Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-25 14:53:47 -07:00
Vishal Rana
2fbaf3a363 minor refactor, #677
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-25 08:08:46 -07:00
Vishal Rana
51723e4c7c removed websocket api
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-20 18:25:40 -07:00
Vishal Rana
d72b8b8b64 fixed docs
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-20 09:10:10 -07:00
Vishal Rana
60ce130499 generic map Map
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-13 16:45:27 -07:00
Vishal Rana
8623669cbc removed Context#P()
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-10-10 18:22:13 -07:00