Coder Social home page Coder Social logo

beh's Introduction

beh

beh - second letter in the hebrew alphabet, after aleph

Overview

This micro-library is a companion to aleph, providing:

  1. metosin/jsonista support for json encode/decode for the aleph http client.
  2. Nested deferred derefencing, which doesn't happend natively w/ aleph
  3. Others...?

This library does not assume versions of aleph or jsonista, and leave the provision of those libraries to you.

See deps.edn for specific versions of the various libraries which have been tested against.

Installation

Currently, only deps.edn is supported, with the only option right now being providing a full git sha.

land.bnert/beh {:git/url "https://github.com/bnert-land/beh"
                :git/sha "HEAD sha"}

io.github.bnert-land/beh {:git/sha "HEAD sha"}

Eventually, a mvn will be released, along w/ a tagged version of the git coordinates above.

Getting Started

jsonista for aleph http client:

(ns exaple.core
  (:require
    [aleph.http :as http]
    [beh.core :as beh]))

(beh/use-jsonista)

(defn -main [_]
  (println
    ; Will use jsonista for encode/decode
    @(http/post "http://localhost:9109"
      {:as :json
       :content-type :json
       :form-params {:ima "teapot"}})))

realizing nested deferred values:

(ns exaple.core
  (:require
    [aleph.http :as http]
    [beh.core :as beh]))


(beh/use-jsonista)

; starts a server
(defn start-server []
  (http/start-server
    (beh/->json-response
      (beh/realize-deferreds
        (fn [req]
          ; Top level deferred is optional
          (d/success-deferred
            {:status 200,
             :headers {"Content-Type" "application/json"}
             :body
             {:thing (d/success-deferred :thing)
              :list  (d/zip (d/success-deferred 0)
                            (d/success-deferred 1)
                            (d/success-deferred 2))
              :go
              {:one
               {:deeper
                 (d/success-deferred "- dj hanzel")}}}}))))
    {:port 9109}))

(defn -main [_]
  (start-server)
  (println
    @(http/post "http://localhost:9109"
      {:as           :json
       :content-type :json
       :form-params  {:ima "teapot"}})))

beh's People

Contributors

bnert avatar

Watchers

 avatar

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.