duct-framework / duct

Server-side application framework for Clojure
MIT License
1.13k stars 51 forks source link

Duct template generates a wrong example handler when combining +api +site #69

Closed iperdomo closed 6 years ago

iperdomo commented 6 years ago

When using +site +api +example the Duct template generates a wrong example handler

$ cd /tmp
$ lein new duct myproject +api +site +example
Generating a new Duct project named myproject...
Run 'lein duct setup' in the project directory to create local config files.
$ $ cat myproject/src/myproject/handler/example.clj 
(ns myproject.handler.example
  (:require [compojure.core :refer :all]
            [clojure.java.io :as io]
            [integrant.core :as ig]))

(defmethod ig/init-key :myproject.handler/example [_ options]
  (context "/example" []
    (GET "/" []
      {:body {:example "data"}}(io/resource "myproject/handler/example/example.html"))))

See that the GET request has 2 return values {:body {:example "data"}} and (io/resource) call

Example of eastwood complaining about the code

$ echo "{:user {:plugins [[jonase/eastwood "0.2.5"]] }}" > $HOME/.lein/profiles.clj
$ cd /tmp/myproject
$ lein eastwood '{:namespaces [myproject.handler.example]}'
== Eastwood 0.2.5 Clojure 1.9.0 JVM 1.8.0_144
== Linting myproject.handler.example ==
Entering directory `/tmp/myproject'
src/myproject/handler/example.clj:9:7: unused-ret-vals: Constant value is discarded: :body
src/myproject/handler/example.clj:9:14: unused-ret-vals: Constant value is discarded: :example
src/myproject/handler/example.clj:9:14: unused-ret-vals: Constant value is discarded: "data"
== Warnings: 3 (not including reflection warnings)  Exceptions thrown: 0
Subprocess failed
weavejester commented 6 years ago

Thanks for the report. This is a duplicate of #68 so I'm closing it. The +site and +api profile hints aren't currently designed to work together.