ring-swagger 2018-10-02

@llsouder has joined the channel

Looking to make a simple rest like api and I found

(sweet/api
 (sweet/GET "/ping" []
            (response/ok {:ping "pong"})))

(def app
  (sweet/api
    (sweet/GET "/hello" []
       :query-params [name :- String]
       (response/ok {:message (str "Hello, " name)}))))

but what do I do with them? neither one produces a route.

tried calling (app) in my (defroutes... that didn't go well.

I am missing a key piece in the examples I am finding.

@llsouder app is a ring-handler (function), you can call it with a request

@ikitommi don't I have to "register" it somewhere? the basic handler examples make a function called handler then do something like (server handler {:port 3000}) or put it in the project.cjl as :ring {:handler handler}

I don't see this working for me since I already have other routes defined.

@llsouder you should register the same way you register other routes handlers

(run-jetty app ... is a way

@mping I am finding lots of handler examples but nothing about the ways to register handlers.

@llsouder how do you start your app?

In the end, I will push to heroku or aws

using the luminus template at the moment

so running an uberjar

how do you configure your app handler?

In a route namespace and using some (defroute... ) stuff

luminus has some nice guides on how to run the app: http://www.luminusweb.net/docs#running_the_application

if you want to compose you top-level ring handler from api & other stuff, you can say:

(def handler
  (->
    (routes api some-other-routes)
    wrap-something))