Skip to content

Commit 2a93f54

Browse files
klamikewaghanza
andauthored
Add Julia HTTP.jl (#8552)
* add HTTP.jl * Apply suggestion from @waghanza Co-authored-by: Marwan Rabbâa <[email protected]> * Apply suggestion from @waghanza Co-authored-by: Marwan Rabbâa <[email protected]> --------- Co-authored-by: Marwan Rabbâa <[email protected]>
1 parent 380dd86 commit 2a93f54

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

julia/http/Project.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[deps]
2+
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
3+
4+
[compat]
5+
HTTP = "1.10"

julia/http/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
github: JuliaWeb/HTTP.jl
3+
version: 1.10

julia/http/deps.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Pkg
2+
3+
Pkg.activate(pwd())
4+
Pkg.Registry.add(RegistrySpec(url = "https://github.com/JuliaRegistries/General"))
5+
Pkg.update()
6+
Pkg.resolve()

julia/http/server.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Pkg
2+
Pkg.activate(pwd())
3+
4+
using HTTP
5+
6+
R = HTTP.Router()
7+
HTTP.register!(R, "GET", "/", (req::HTTP.Request) -> HTTP.Response(200, ""))
8+
HTTP.register!(R, "GET", "/user/{id}", (req::HTTP.Request) -> HTTP.Response(200, HTTP.getparams(req)["id"]))
9+
HTTP.register!(R, "POST", "/user", (req::HTTP.Request) -> HTTP.Response(200, ""))
10+
HTTP.serve(R, "0.0.0.0", 3000)

0 commit comments

Comments
 (0)