# GenServer processing

**URL:** <https://forum.elixirforum.com/t/genserver-processing/15691>\
**Category:** Questions\
**Tags:** api, phoenix, http, maru, genserver\
**Created:** [August 8, 2018, 12:21pm UTC](https://forum.elixirforum.com/t/genserver-processing/15691 "2018-08-08T12:21:50Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ayhan.rashidov](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/d9b06d/32.png) [@ayhan.rashidov](https://forum.elixirforum.com/u/ayhan.rashidov)\
**Post date:** [August 8, 2018, 12:33pm UTC](https://forum.elixirforum.com/t/genserver-processing/15691/3 "2018-08-08T12:33:55Z")

</div>

Here is an example.

HTTP Server.

```elixir
defmodule HttpSrv do

  use Maru.Router
  plug(Plug.Logger)
  require Logger
  plug CORSPlug

  post do
    Logger.info("[Maru] Received a post request.")
  
    ## Start the processing of each request
    resp = Calculator.calc(5, 5)
    Maru.Response.json(conn, %{response: resp})
  end

end

```

The GenServer module.

```elixir
defmodule Calculator do

  use GenServer
  require Logger

  ## Client API

  def start_link(_arg) do
    GenServer.start_link( __MODULE__ , :ok, name: __MODULE__ )
  end

  def calc(a, b) do
    GenServer.call( __MODULE__ , {:calc, a, b}, :infinity)
  end

  ## Server Callbacks

  def init(:ok) do
    {:ok, %{}}
  end

  def handle_call({:calc, a, b}, _from, state) do
    result = a + b
    {:reply, result, state}
  end

end

```

---

_[View the full topic](https://forum.elixirforum.com/t/genserver-processing/15691)._
