Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hden/apex-rpc
Simple RPC style APIs with generated clients.
https://github.com/hden/apex-rpc
Last synced: 28 days ago
JSON representation
Simple RPC style APIs with generated clients.
- Host: GitHub
- URL: https://github.com/hden/apex-rpc
- Owner: hden
- License: other
- Created: 2020-08-16T13:54:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T01:06:52.000Z (4 months ago)
- Last Synced: 2024-10-03T12:16:41.861Z (3 months ago)
- Language: Clojure
- Size: 71.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# apex-rpc ![Build Status](https://circleci.com/gh/hden/apex-rpc.svg?&style=shield) [![codecov](https://codecov.io/gh/hden/apex-rpc/branch/master/graph/badge.svg)](https://codecov.io/gh/hden/apex-rpc)
Clojure client for https://github.com/apex/rpc
## Usage
```clojure
(require '[apex-rpc.core :refer [call]])(call {:url "http://localhost:18080"
:method "get_headers"
:auth-token "token"
:args-map {:foo "bar"}})
```Or you can choose to generate syntax sugar from the schema.json.
```sh
./script/gen.clj gen -i examples/todo.json -n myclient.core > myclient.clj
```**Generated client**
```clojure
;; myclient.clj
;; Do not edit, this file was generated by github.com/hden/apex-rpc.(ns myclient
(:require [apex-rpc.core :refer [call]]))(defn add-item
"adds an item to the list."
[spec arg-map]
(call (merge spec {:method "add_item" :arg-map arg-map})))(defn get-items
"returns all items in the list."
[spec arg-map]
(call (merge spec {:method "get_items" :arg-map arg-map})))(defn remove-item
"removes an item from the to-do list."
[spec arg-map]
(call (merge spec {:method "remove_item" :arg-map arg-map})))```
**Use it from your code**
```clojure
(require '[myclient.core :as myclient])(def conn {:url "http://localhost:18080"
:auth-token "token"})(myclient/add-item conn {:item "foobar"})
```## License
Copyright © 2020 Haokang Den
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
at https://www.gnu.org/software/classpath/license.html.