Giter Club home page Giter Club logo

catacumba's Introduction

Catacumba

WARNING: this project is not longer maintaned. If somebody want to continue maintaining it write me a PM. I stop maintaining it because the lack of progress on the ratpack side and i have plans on work on a similar (smaller and simlier) toolkit using vertx.

The asynchronous web toolkit for clojure built on top of Ratpack

Clojars Project

See the documentation or api reference for more detailed information.

catacumba's People

Contributors

christoph-frick avatar cryptox8 avatar dspearson avatar jordillonch avatar kardan avatar mitchelkuijpers avatar moea avatar niwinz avatar pepegar avatar podviaznikov avatar prepor avatar source-c avatar stask avatar timgluz avatar trieloff avatar tyler-anderson avatar warrendev3190 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

catacumba's Issues

Add support for files from classpath

Hi I would like to server my assets from classpath I went into the documentation of ratpack and I found this: http://ratpack.io/manual/current/launching.html#base_dir

This basically means if you want to serve assets from the classpath you need to create a markerfile .ratpack and catacumba should call http://ratpack.io/manual/current/api/ratpack/server/ServerConfig.html#findBaseDir-java.lang.String- when you don't set a basedir (Or maybe this should be an option?). Would you like a pull request with this change?

Testing helpers.

Expose some convenience macros for make test catacumba application easier!

Best way to get a Guice registry in?

I currently use attach-route, but reaching into the impl namespace feels somewhat unclean.

(defmethod catacumba.impl.routing/attach-route :guice-registry
  [^Chain chain [_ binding-spec]]
  (.register chain
             (.apply
              (Guice/registry ^Action (ch/fn->action ^BindingsSpec binding-spec))
              (.getRegistry chain))))

I saw now way to do it in :setup and the initial creation of the registry is done in a private fn.

cookie as session store

Hello! How to implement signed-cookie based session store? For setup cookies we need access to context or use returned value from write-session as new session key (like ring session stores).

Broken dependency?

I am very new to clojure and now was giving catacumba a try (with leiningen).

Following the instructions in the quick start area, there is an error by retrieving the dependencies after lein run:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.IncompatibleClassChangeError: Method ratpack.server.RatpackServer.of(Lratpack/func/Action;)Lratpack/server/RatpackServer; must be InterfaceMethodref constant, compiling:(/tmp/form-init11947645225559549126.clj:1:74) at clojure.lang.Compiler.load(Compiler.java:7391) at clojure.lang.Compiler.loadFile(Compiler.java:7317) at clojure.main$load_script.invokeStatic(main.clj:275) at clojure.main$init_opt.invokeStatic(main.clj:277) at clojure.main$init_opt.invoke(main.clj:277) at clojure.main$initialize.invokeStatic(main.clj:308) at clojure.main$null_opt.invokeStatic(main.clj:342) at clojure.main$null_opt.invoke(main.clj:339) at clojure.main$main.invokeStatic(main.clj:421) at clojure.main$main.doInvoke(main.clj:384) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:383) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: java.lang.IncompatibleClassChangeError: Method ratpack.server.RatpackServer.of(Lratpack/func/Action;)Lratpack/server/RatpackServer; must be InterfaceMethodref constant at catacumba.impl.server$run_server.invokeStatic(server.clj:145) at catacumba.impl.server$run_server.invoke(server.clj:109) at cata_web.core$_main.invokeStatic(core.clj:15) at cata_web.core$_main.doInvoke(core.clj:13) at clojure.lang.RestFn.invoke(RestFn.java:397) at clojure.lang.Var.invoke(Var.java:375) at user$eval5.invokeStatic(form-init11947645225559549126.clj:1) at user$eval5.invoke(form-init11947645225559549126.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6927) at clojure.lang.Compiler.eval(Compiler.java:6917) at clojure.lang.Compiler.load(Compiler.java:7379) ... 14 more

As I unterstand, it is a problem with the SLF4J-dependency?

Thankfull for every help.

:assets as root resource

I'm experimenting with Catacumba, and likely doing something wrong. This route entry:

[:assets "x" {:dir "public" :indexes ["index.html"]}]

Behaves as I would expect, when I visit /x (provided I've a .catacumba in resources/). This one:

[:assets "" {:dir "public" :indexes ["index.html"]}]

Only serves the index page at /, with a 404 for any static child resources (CSS, JS, in this case). How would I go about serving static content at the root of the resource tree? Please excuse me if I've missed something obvious.

Routing params and prefix

Hello. Thanks for great work!

As I understand from ratpack's documentation route params (also known as path tokens) should be proxied through nested handlers. But this example doesn't work for me:

(def routes
  [[:prefix "api/v1"
    [:get status]
    [:get "feeds" feeds]
    [:prefix "chats/:id"
     [:get chat-info]]]])

api/v1/chats/10 has empty route-params

but:

(def routes
  [[:error error!]
   [:get index]
   [:prefix "api/v1"
    [:get status]
    [:get "feeds" feeds]
    [:get "chats/:id" chat-info]]])

Works as expected and has {:id 1} in :route-params

Why? Thanks!

Add new approach for polymorphic handler adapters.

The current one tends to be verbose and ugly, and has some drawbacks (such as when you define metadata in a function, the metadata is associated with the var and not a function and this causes unexpected behavior)

Add example to README on how to stop the server

I did a little bit of research and found (.stop ratpack-server-from-run-server) but it's not clearly defined how to do it. A little example on this in the docs or the README (ideally both) would be welcoming ๐Ÿ˜„

Add restfull handlers support.

The proposal is do something like this:

;; Using protocols

(def myresource
  (reify IResource
    IResourceIndex
    (-index [context]
      (http/ok "foobar"))

    IResourceShow
    (-show [context]
      (http/ok "foobar"))

    IResourceCreate
    (-create [context]
      (http/created "foobar"))

    IResourceUpdate
    (-update [context]
      (http/ok "foobar"))

    IResourceDelete
    (-delete [context]
      (http/ok "foobar"))))

;; Using multimethods

(defmulti myresource
  (fn [type context] type))

(defmethod myresource :index
  [_ context]
  (http/ok "foobar"))

(defmethod myresource :show
  [_ context]
  (http/ok "foobar"))

(defmethod myresource :create
  [_ context]
  (http/ok "foobar"))

(defmethod myresource :update
  [_ context]
  (http/ok "foobar"))

(defmethod myresource :delete
  [_ context]
  (http/ok "foobar"))


;; Using plain functions and hash-maps

(defn index
  [contex]
  (http/ok "foobar"))

(defn show
  [contex]
  (http/ok "foobar"))

(defn create
  [contex]
  (http/ok "foobar"))

(defn update
  [contex]
  (http/ok "foobar"))

(defn delete
  [contex]
  (http/ok "foobar"))

(def myresource
  {:index index
   :show show
   :create create
   :update update
   :delete delete})

And it will be used in this way:

(require '[catacumba.handlers.restfull :as rest])
(ct/routes [[:prefix "api/v1"
             (rest/resource "authors" myauthorresource)
             (rest/resource "books" mybooksresource)]])

compchat example is broken

I try starting the system in compchat.core from the REPL like so:

(def system (application-system))
(alter-var-root #'system component/start)
[nREPL-worker-0] INFO ratpack.server.RatpackServer - Starting server...
[nREPL-worker-0] INFO ratpack.server.RatpackServer - Building registry...
[nREPL-worker-0] INFO ratpack.server.RatpackServer - Ratpack started for http://localhost:5050
[nREPL-worker-0] INFO ratpack.server.RatpackServer - Stopping server...
[nREPL-worker-0] INFO ratpack.server.RatpackServer - Server stopped.
[nREPL-worker-0] INFO ratpack.server.RatpackServer - Starting server...
[nREPL-worker-0] INFO ratpack.server.RatpackServer - Building registry...
[nREPL-worker-0] INFO ratpack.server.RatpackServer - Ratpack started for http://localhost:5050

and it starts. When I try to access index.html page, I get this error in the console:

[ratpack-compute-4-2] WARN ratpack.error.internal.DefaultProductionErrorHandler - Default production error handler used to render server error, please add a ratpack.error.ServerErrorHandler instance to your application (method: GET, uri: /)

java.lang.ClassCastException: clojure.lang.PersistentHashMap cannot be cast to ratpack.handling.Chain
    at catacumba.impl.routing$eval14735$fn__14737.invoke(routing.clj:80)
...

route-params fails with nested handlers

If you create routes like this

[routes [[:assets "public" {:dir "public"}]
         [:any (utils/with-db database)]
         [:prefix "ui/index/:part"
         [:any  atlassian/check-token-from-jira-handler]
         [:by-method {:get index}]]]]

in the index function route-params is always empty.. maybe because it caches the context from the utils/with-db handler? When I place the utils/with-db higher (after the prefix then everything has the :part parameter again in the route-params map)

Don't start in development mode by default

Catacumba should not start in development mode by default, because it adds complexity for people running it in production. Following the principles of:

  • Explicit is better than implicit.
  • Simple is better than complex.
    We should make the debug mode an explicit choice (instead of an implicit default) and make it simple to run and operate catacumba

Websocket example

Tried to get the websocket example running.

Replaced [catacumba.handlers :as hs] with [catacumba.handlers.misc :as hs]
in the namesspace websocket-echo.core

Then in the browser I get

WebSocket connection to 'ws://localhost:5050/ws' failed: Error during WebSocket handshake: Unexpected response code: 200

Are interceptors implemented?

I noticed that there is an interceptors example in the examples/ folder, but the tests for interceptor in commented out.

Improve CSRF api

Allowing obtain the current csrf token in the handler (not only by javascript).

Uploading a file

Hi,

Just wanted to add a snippet of uploading a file example:

(defn upload [{:keys [data]}]
  (.writeTo (:file data) (java.io/FileOutputStream. (str "./downloads/" (.getFileName (:file data))))))

Enjoy!

Stop server

The documentation says: "If you want to stop the server, you just need to call the .close method on the object returned by the run-server function."

There is no .close method on server. The correct method is .stop !
Could you please change the documentation ?

Thanks,
G.Scacco

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.