# Implement a REST server in Julia?

**URL:** <https://discourse.julialang.org/t/implement-a-rest-server-in-julia/9117>\
**Category:** Web Stack\
**Created:** [February 16, 2018, 6:55pm UTC](https://discourse.julialang.org/t/implement-a-rest-server-in-julia/9117 "2018-02-16T18:55:37Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![rssdev10](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@rssdev10](https://discourse.julialang.org/u/rssdev10)\
**Post date:** [November 15, 2018, 7:32pm UTC](https://discourse.julialang.org/t/implement-a-rest-server-in-julia/9117/14 "2018-11-15T19:32:50Z")

</div>

Some personal experience of JSON processing in a request and generating JSON as a response:

Implementation with Mux:

```julia
using Mux
using JSON

@app test = (
  Mux.defaults,
  page(respond("<h1>Hello World!</h1>")),

  page("/user/:user", req -> "<h1>Hello, $(req[:params][:user])!</h1>"),

  route("/resource/process", req -> begin
    obj = JSON.parse(String(req[:data]))

    @show obj

    Dict(:body => String(JSON.json(obj)),
         :headers => Dict("Content-Type" => "application/json")
         )
  end),

  Mux.notfound())

serve(test, 8080)

Base.JLOptions().isinteractive == 0 && wait()

```

Implementation with Bukdu:

```julia
using Bukdu
using JSON

struct WelcomeController <: ApplicationController
    conn::Conn
end

function index(c::WelcomeController)
    render(JSON, "Hello World")
end

function process_resource(c::WelcomeController)
    json = JSON.parse(String(c.conn.request.body))

    @show json

    render(JSON, json)
end

routes() do
    get("/", WelcomeController, index)
    post("/resource/process", WelcomeController, process_resource)
end

Bukdu.start(8080)

Base.JLOptions().isinteractive == 0 && wait()

```

---

_[View the full topic](https://discourse.julialang.org/t/implement-a-rest-server-in-julia/9117)._
