Coder Social home page Coder Social logo

marcliberatore / shoreleave-remote Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shoreleave/shoreleave-remote

0.0 2.0 0.0 147 KB

A smarter client-side with ClojureScript : Shoreleave's rpc/xhr/jsonp facilities

License: Eclipse Public License 1.0

shoreleave-remote's Introduction

shoreleave

A smarter client-side in ClojureScript

###Shoreleave is a collection of integrated libraries that focuses on:

  • Security
  • Idiomatic interfaces
  • Common client-side strategies
  • HTML5 capabilities
  • ClojureScript's advantages

It builds upon efforts found in other ClojureScript projects, such as Fetch and ClojureScript:One.

Shoreleave-remote Overview

The remote namespace provides CSRF-protected and consistent interfaces for XHR, Pooled XHR, JSONP, and HTTP-RPC calls.

The CSRF protection is automatic if your Clojure server is using the ring-anti-forgery middleware.

The HTTP-RPC is built upon Fetch and allows for exposing a server-side namespace as a client-side API, via a single server-side call, remote-ns.

Please see the Marginalia docs for more information.


A typical Noir setup might look like:

(ns example
  (:require [noir.shoreleave.rpc :as rpc]))

;; ...

;; The Base Web Server
;; ---------------------
;; Serve every view file found in `src/example/views`
(server/load-views "src/example/views/")

;; Remote Namespaces
;; -----------------
(rpc/activate-remotes!)
(rpc/remote-ns 'example.api :as "api") ; Note, you don't have to include example.api in this .clj file

;; Middleware
;;-----------
(server/add-middleware ring.middleware.gzip/wrap-gzip)
(server/add-middleware ring.middleware.file-info/wrap-file-info)
(server/add-middleware ring.middleware.anti-forgery/wrap-anti-forgery)

You can also define single "global" rpc functions:

(defremote ping []
  (do
    (println "Pinged by client!")
    "PONG - from the server"))

Plays well with others

Shoreleave makes no assumptions about other libraries you might be using in your app.

I have found it to pair particularly well with Enfocus

Examples and usage

Please the github wiki for examples of each library feature

License

Copyright © 2012 Paul deGrandis

Distributed under the Eclipse Public License, the same as Clojure. Please see the LICENSE_epl.html for details.

shoreleave-remote's People

Contributors

ohpauleez avatar

Watchers

James Cloos avatar Marc Liberatore 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.