GithubHelp home page GithubHelp logo

xyhp915 / clojureworker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sauercrowd/clojureworker

0.0 0.0 0.0 90 KB

Home Page: https://clojars.org/com.github.sauercrowd/clojureworker

License: MIT License

Shell 2.24% Clojure 97.76%

clojureworker's Introduction

clojureworker

Clojars Project

A Clojurescript library to simplify the use with Cloudflare workers, focusing on simplicity.

Usage

Clojureflare currently provides three functions, documented here.

  • worker, which routes as arguments and attaches the dispatcher to the worker event
  • simulate-worker, serving the same purpose. It acceps a request as a first argument and instead of responding to a worker event returns the response, which simplifies repl development. It avoids any dependencies that would limit the runtime to the browser.
  • route, creating a new route which expects three argument: method (e.g. GET, POST), path (such as /api/v1/ping) and handler (described below).

The Handler

The handler can currently be one of three types:

  • a string, which will generate a static HTML response
  • a map, which will generate a static JSON response
  • a function, which will receive the request as a parameter and returns a response map

The request is of the form of

{:path "/test" :body "{\"key\":1}" :headers {}}

while the response map should similar to

{:body "{\"key\":1}" :headers {"Content-Type" "application/json"} :status 200}

Additionally the handler function can return a promise which eventually resolves to the described map.

Example Worker

Head over to the example-worker to create your first Clojurescript worker.

clojureworker's People

Contributors

sauercrowd avatar xyhp915 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.