Fork me on GitHub
#ring-swagger
<
2018-10-02
>
llsouder00:10:13

Looking to make a simple rest like api and I found

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

llsouder00:10:50

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

llsouder00:10:39

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

llsouder00:10:13

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

llsouder00:10:56

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

ikitommi03:10:47

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

llsouder09:10:07

@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}

llsouder09:10:12

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

mping10:10:37

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

mping10:10:11

(run-jetty app ... is a way

llsouder10:10:17

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

mping10:10:33

@llsouder how do you start your app?

llsouder10:10:53

In the end, I will push to heroku or aws

llsouder11:10:17

using the luminus template at the moment

llsouder11:10:51

so running an uberjar

mping11:10:18

how do you configure your app handler?

llsouder11:10:11

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

ikitommi11:10:51

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

ikitommi11:10:34

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))