Skip to content

Expose Datahike Server Namespace #736

@alekcz

Description

@alekcz

Describe the feature you would like to request

I would like to be able add the datahike.server.http routes and functionality in to my current ring server (http-kit).

Describe the solution you would like

I would like the datahike.http.server namespace to be available in the datahike library (io.replikativ/datahike). With thisinternal-writer-routes exposed.

I would like to be able to do something like this (taken from reitit example code):

(def app
  (ring/ring-handler
    (ring/router
     (concat 
>>>>> (dhs/internal-writer-routes datahike-config)
      ["/api"
       ["/math" {:get {:parameters {:query {:x int?, :y int?}}
                       :responses  {200 {:body {:total int?}}}
                       :handler    (fn [{{{:keys [x y]} :query} :parameters}]
                                     {:status 200
                                      :body   {:total (+ x y)}})}}]])
      ;; router data affecting all routes
      {:data {:coercion   reitit.coercion.spec/coercion
              :muuntaja   m/instance
              :middleware [parameters/parameters-middleware ; decoding query & form params
                           muuntaja/format-middleware       ; content negotiation
                           exception/exception-middleware   ; converting exceptions to HTTP responses
                           rrc/coerce-request-middleware
                           rrc/coerce-response-middleware
>>>>>>>>>>>>>>>>>>>>>>>>>> dhs/datahike-middleware]}})))


Describe alternatives you've considered

I maintained my on fork of https://github.com/replikativ/datahike-server for 3 years but the maintenance overhead was not sustainable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions