https://github.com/clj-commons/slingshot -- Enhanced try and throw for Clojure leveraging Clojure's capabilities -- has moved to clj-commons for maintenance and future development:
org.clj-commons/slingshot {:mvn/version "0.13.0"} should be functionally identical to slingshot/slingshot {:mvn/version "0.12.2"} but the namespaces have changed to have a clj-commons prefix to avoid conflicts with older versions on the classpath, since this is such a widely-used library:
• add clj-kondo config export
• move to clj-commons; rename nses to clj-commons.*
• switch to CLI / deps.edn / build.clj / bb.edn
• add GitHub Actions for CI
• drop support for Clojure 1.7 and earlier
• clean up use and refer all
Note: slingshot/slingshot supported Clojure 1.4 onward (although the test suite was failing on 1.8 onward). org.clj-commons/slingshot officially supports Clojure 1.8 through 1.12 and may work on earlier versions. Given the time passed since 0.12.2, this seemed a reasonable modernization. Follow-up in #slingshot
@borkdude There are some changes in clj-kondo support here that you may want to merge back into the core for the original slingshot.slingshot namespaces -- https://github.com/clj-commons/slingshot/blob/release/resources/clj-kondo.exports/org.clj-commons/slingshot/clj_kondo/clj_commons/slingshot.clj
Thanks! I'd be happy to forward any existing slingshot users to this new repo though.
@seancorfield 1. Thank you for doing all this, your contributions to the Clojure ecosystem are amazing! 2. I have a "dumb" question about slingshot, which you are under no obligation to answer/respond-to: When I first encountered slingshot years ago, I thought it was great, and started using it extensively. OTOH, when I am developing a library that has aspirations of being used by others, my use of slingshot (for exceptions that might "escape" from my code) feels wrong, because I'm now forcing users of my library to deal with slingshot, and they may not want that. Any advice you might offer me here would be appreciated...
I think you're on the right track if I may add my 2 cts, avoiding additionals deps for libraries is a great idea
@dcj 1. Thank you! gratitude 2. As Michiel says, libraries really should keep dependencies to a minimum and should be careful about the "API" they expose -- which includes exceptions the library can throw. I think it would be okay for a library to use Slingshot internally but you would need to be very careful that any exceptions that "escape" are either plain Java exceptions or ex-info (and document them well).
In next.jdbc I decided it was reasonable to depend on org.clojure/java.data -- for one small piece of functionality -- because that's a Contrib lib and very stable and changes very slowly, so there's less likelihood of version conflicts.
@dcj, you can just throw standard ex-info exceptions and then use Slingshot’s try+/catch macro to catch them if you want to catch based on something in the ex-info map. If those exceptions escape, they are just standard Clojure ex-info exceptions. Slingshot is also not heavyweight as far as libraries go. It’s a few macros, basically. So, yea, while it’s always better to be dependency free, it wouldn’t be the worst library to use.
@seancorfield, you probably want to update the Status section of the README.md file in the new repo. It’s got status info in there dated 2019.
@droberts3 can you create an issue on the repo with specifics? I'm not at my computer right now and I don't want that to get lost - it's a really good point.
Sure, will do
done
io.pedestal/pedestal 0.8.0
https://pedestal.io is a framework that brings Clojure’s key attributes, Focus, Empowerment, and Simplicity, to the domain of Clojure web development.
Version 0.8.0 represents more than a year of steady improvements.
OVERVIEW:
• Routing
◦ New Sawtooth router favors literal paths over those with path parameters, and can report any routing conflicts
◦ WebSocket upgrade requests now go through routing, the same as any other endpoint (previously handled as special case)
◦ Static files (file system or on JVM classpath) now also go through routing (previously handled via interceptors)
• Servlet Support
◦ Upgraded to Jetty 12
• Non-Servlet Support
◦ Pedestal APIs that require Jakarta Servlet APIs are now in a new module, io.pedestal/pedestal.servlet
◦ Pedestal now supports non-servlet based HTTP libraries, such as https://github.com/http-kit/http-kit
• Developer Experience
◦ io.pedestal.http replaced with simpler, streamlined io.pedestal.connector
◦ Improved REPL-oriented development, compatible with https://github.com/tonsky/clj-reload
◦ New definterceptor to create a record type that can be used as an interceptor
◦ Significant improvements to all documentation
BREAKING CHANGES:
• Clojure 1.11 is now the minimum supported version
• The new Sawtooth router is now the default router
• Anonymous interceptors are deprecated
• Many APIs deprecated in Pedestal 0.7.0 have been removed outright
• The io.pedestal/pedestal.service-tools library has been removed
• Significant changes to io.pedestal.http.route have occurred
• Server-Sent Events have been changed; fields are now terminated with a single \n rather than a \r\n (both are acceptible according to the SSE specification)
• The io.pedestal.http.body-params/body-params interceptor now does nothing if the request :body is nil
• Exceptions in interceptors:
◦ The caught exception is now the ex-cause of the exception provided (in earlier releases, it was the :exception
key of the data)
◦ The logic for when to suppress an exception thrown from the error handling interceptor has been simplified: always
suppress except when the interceptor rethrows the exact error passed to it
• io.pedestal.test has been rewritten, nearly from scratch
◦ The Servlet API mocks are now standard Java classes, not reify-ed classes
◦ A request body may now be a java.io.File
• io.pedestal.http.servlet
◦ The reify’ed FnServlet class is now a standard Java class, io.pedestal.servlet.FnServlet
◦ The new FnServlet extends HttpServlet not Servlet
• Deleted deprecated namespaces:
◦ io.pedestal.http.request
◦ io.pedestal.http.request.lazy
◦ io.pedestal.http.request.zerocopy
• Deleted vars (previously deprecated):
◦ io.pedestal.http
▪︎ json-print
◦ io.pedestal.http.body-params
▪︎ add-ring-middleware
▪︎ edn-parser
▪︎ json-parser
▪︎ transit-parser
◦ io.pedestal.http.ring-middlewares
▪︎ response-fn-adapter
◦ io.pedestal.http.impl.servlet-interceptor
▪︎ stylobate
▪︎ terminator-injector
• Other deleted vars and namespaces:
◦ io.pedestal.http.route.definition/symbol->keyword
◦ io.pedestal.http.route.definition/capture-constraint
◦ io.pedestal.http.request.servlet-support
Newly deprecated namespaces (these may be removed or made non-public in the future):
• io.pedestal.jetty.container
• io.pedestal.jetty.util
• io.pedestal.http
• io.pedestal.http.test
Other changes:
• Pedestal Connectors are a new abstraction around an HTTP library such as Jetty or Http-Kit
◦ Connectors do not use the Servlet API, and so are much lighter weight
◦ The io.pedestal.connector namespace is used to configure and start a Pedestal connector
• A new router, io.pedestal.http.route.sawtooth, has been added
◦ Sawtooth identifies conflicting routes
◦ Sawtooth prefers literal routes over routes with path parameters (i.e., /users/search vs. /users/:id)
◦ Sawtooth is the now the default router
• When converting a handler function to an Interceptor
◦ Handler functions may now be asynchronous, returning a channel that conveys the response map
◦ The :name metadata on the function will be used as the :name of the interceptor
◦ Otherwise, a :name is derived from the function’s class
◦ Previously, with the terse or verbose routing specifications, the route name would overwrite the (missing) name
of the interceptor; now interceptors always have names and this does not occur
◦ Extracting default interceptor names from handlers can also be turned off, reverting to 0.7.x behavior
• The new definterceptor macro is used to concisely define a record type that can be used as an interceptor, but also as a https://github.com/stuartsierra/component
• Development mode is now configured as with other values, rather than strictly via a JVM system property
• Deprecation warnings may now be suppressed
• Fixed reloading behavior when namespaces are reloaded via https://github.com/tonsky/clj-reload
• Metrics can now be configured to accept longs or doubles as their values
• io.pedestal.connector.servlet and new Java class ConnectorServlet allow for WAR deployments
• WebSockets are now routable like other requests, using new function io.pedestal.websocket/upgrade-request-to-websocket
• The pedestal.service module has been broken up; all the parts specific to the Jakarta Servlet API are
now in the new pedestal.servlet module
• io.pedestal.http.route.definition.table
• Table routes may now specify :interceptors (in the options map); these are prefixed on any
interceptors provided by the routes in the table
• Table routes may now include application-defined key/value pairs in addition to :route-name and :constraints
• The first argument to table-routes may now be nil or a map
• io.pedestal.http.jetty
• It is now possible to specify the maximum number of concurrent threads with the Jetty HTTP2 and HTTP2C connection
factories
• It is now possible to specify WebSocket configuration (buffer sizes, timeouts)
• New functions and macros:
◦ io.pedestal.test/create-responder - useful piece needed in most tests
◦ io.pedestal.interceptor/definterceptor - easily create component records that transform into interceptors
◦ io.pedestal.log/log - logs with level determined at runtime
• New namespaces:
◦ io.pedestal.connector - Replaces io.pedestal.http for setting up a connector
◦ io.pedestal.service.protocols - Defines core protocols
◦ io.pedestal.service.resources - Expose resources using routes not interceptors
◦ - Development/debugging tools
◦ io.pedestal.service.interceptors - Common interceptors
◦ io.pedestal.connector.test - Testing w/ Ring request and response (no Servlet API)
◦ io.pedestal.connector.servlet - bridge to Pedestal from a WAR deployment
• The io.pedestal.http.cors/allow-origin interceptor now, by default, logs at level debug (was level info previously)
• The embedded template now generates a less rudimentary index page, with basic styling
https://github.com/pedestal/pedestal/milestone/17?closed=1
Nice! Sawtooth, where have you been all my life! 😄
That's a list...
0.8.0 is somewhat of a sea change for Pedestal; previously it was tacit that the Servlet API was present, and it took a lot of effort to tease that concept apart to support non-servlet containers such as httpkit.