Skip to content

Instantly share code, notes, and snippets.

@stevegraham
Created August 24, 2015 16:17
Show Gist options
  • Save stevegraham/a319cc39dfc02fbb8a78 to your computer and use it in GitHub Desktop.
Save stevegraham/a319cc39dfc02fbb8a78 to your computer and use it in GitHub Desktop.

http: [compress: true] is set on App.Endpoint

defmodule App.Router do
  use Phoenix.Router

  scope "/", App do
    resources "foo", FooController do
  end
end

defmodule App.FooController do
  use App.Web, :controller

  plug :action

  def index(conn, _params) do
    conn |> json %{ "lol" => true }
  end
end

The following request:

╰─$ curl --compress -v http://0.0.0.0:4000/foo
* About to connect() to 0.0.0.0 port 4000 (#0)
*   Trying 0.0.0.0...
* Adding handle: conn: 0x7ffbb8803a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7ffbb8803a00) send_pipe: 1, recv_pipe: 0
* Connected to 0.0.0.0 (0.0.0.0) port 4000 (#0)
> GET /foo HTTP/1.1
> User-Agent: curl/7.30.0
> Host: 0.0.0.0:4000
> Accept: */*
> Accept-Encoding: deflate, gzip
> 
< HTTP/1.1 200 OK
< connection: keep-alive
* Server Cowboy is not blacklisted
< server: Cowboy
< date: Mon, 24 Aug 2015 16:09:12 GMT
< content-length: 12
< content-type: application/json; charset=utf-8
< cache-control: max-age=0, private, must-revalidate
< x-request-id: GOCUWkbzTWzpnkJV4ioK
< 
* Connection #0 to host 0.0.0.0 left intact
{"lol":true}%  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment