diff --git a/website/content/guide/response.md b/website/content/guide/response.md index 1d27a361..dde86bf2 100644 --- a/website/content/guide/response.md +++ b/website/content/guide/response.md @@ -66,6 +66,15 @@ Context.JSON(code int, v interface{}) error Sends a JSON HTTP response with status code. +### JSONP + +```go +Context.JSONP(code int, callback string, i interface{}) error +``` + +Sends a JSONP HTTP response with status code. It uses `callback` to construct the +JSONP payload. + ### XML ```go @@ -93,11 +102,12 @@ Sends a text/plain HTTP response with status code. ### File ```go -Context.File(name string, attachment bool) error +Context.File(name, path string, attachment bool) error ``` -File sends a response with the content of the file. If attachment is `true`, the client -is prompted to save the file. +File sends a response with the content of the file. If `attachment` is set +to `true`, the client is prompted to save the file with provided `name`, +name can be empty, in that case name of the file is used. ### Static files diff --git a/website/content/guide/routing.md b/website/content/guide/routing.md index 8763f667..65031c1f 100644 --- a/website/content/guide/routing.md +++ b/website/content/guide/routing.md @@ -21,6 +21,10 @@ e.Get("/hello", func(c *echo.Context) error { }) ``` +You can use `Echo.Any(path string, h Handler)` to register a handler for all HTTP methods. +To register it for some methods, use `Echo.Match(methods []string, path string, h Handler)`. + + Echo's default handler is `func(*echo.Context) error` where `echo.Context` primarily holds HTTP request and response objects. Echo also has a support for other types of handlers.