Comments (4)
Implementation of JSON request processing with Mux:
using Mux
using JSON
@app test = (
Mux.defaults,
page(respond("<h1>Hello World!</h1>")),
page("/user/:user", req -> "<h1>Hello, $(req[:params][:user])!</h1>"),
route("/resource/process", req -> begin
obj = JSON.parse(String(req[:data]))
@show obj
Dict(:body => String(JSON.json(obj)),
:headers => Dict("Content-Type" => "application/json")
)
end),
Mux.notfound())
serve(test, 8080)
Base.JLOptions().isinteractive == 0 && wait()
Implementation of JSON request processing with Bukdu:
using Bukdu
using JSON
struct WelcomeController <: ApplicationController
conn::Conn
end
function index(c::WelcomeController)
render(JSON, "Hello World")
end
function process_resource(c::WelcomeController)
json = JSON.parse(String(c.conn.request.body))
@show json
render(JSON, json)
end
routes() do
get("/", WelcomeController, index)
post("/resource/process", WelcomeController, process_resource)
end
Bukdu.start(8080)
Base.JLOptions().isinteractive == 0 && wait()
from juliawebapi.jl.
The primary purpose of this package is to enable exposing Julia functions as web APIs. Right now, the path elements are mapped to function parameters and query/form name-value pairs are mapped on to keyword args.
I unsure how requests with JSON body should fit to this paradigm.
Mux does seem to be a good alternative for this.
from juliawebapi.jl.
Actually Web APIs primary means usage of some exchange format like JSON or XML. Just as example - https://market.mashape.com/ or open API initiative https://www.openapis.org/ But in both cases it requires usage of POST request with some HTTP body content.
In general it is not so big issue to add support of multipart HTTP content at least for JSON. But primary it is depends on how are you positioning the library.
from juliawebapi.jl.
- https://graphql.org as new conception of web API with JSON like input and output....
from juliawebapi.jl.
Related Issues (20)
- Add to METADATA? HOT 7
- ArgumentError: cannot convert NULL to string HOT 2
- JuliaWebAPI v0.0.2 fails tests in Linux HOT 1
- Tests fail on v0.5 HOT 5
- Error running example from README HOT 2
- Tag a new release?? HOT 2
- Error tagging new release HOT 1
- Expose a module via a ZMQ listener HOT 1
- Interrupting process() exits julia runtime HOT 4
- Ability to add endpoints and redefine functions without restarting HOT 1
- MacOS test failure in http rpc tests HOT 1
- No method matches process(::Array{Tuple... HOT 1
- How to terminate server process? HOT 1
- Noob question: "function X does not accept keyword arguments" error HOT 2
- How to close HTTP RPC Server?
- Where can I configure the maximum size of a request? HOT 1
- JuliaWebAPI is being used by https://chloe.plantenergy.edu.au HOT 1
- TagBot trigger issue HOT 1
- Tests hang at test_httprpc.jl
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from juliawebapi.jl.