Skip to content

Commit

Permalink
feature/routing-functions (#112)
Browse files Browse the repository at this point in the history
1.) Added support for routing functions
2.) converted the @register macro into a regular function
3.) demo files now use Julia v1.6.6
  • Loading branch information
ndortega authored Jun 4, 2023
1 parent 655eb31 commit f3af6c7
Show file tree
Hide file tree
Showing 13 changed files with 475 additions and 234 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Oxygen"
uuid = "df9a0d86-3283-4920-82dc-4555fc0d1d8b"
authors = ["Nathan Ortega <[email protected]>"]
version = "1.1.8"
version = "1.1.9"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Breathe easy knowing you can quickly spin up a web server with abstractions you'

## Features

- Straightforward routing (`@get`, `@post`, `@put`, `@patch`, `@delete` and `@route` macros)
- Straightforward routing
- Auto-generated swagger documentation
- Out-of-the-box JSON serialization & deserialization (customizable)
- Type definition support for path parameters
Expand Down Expand Up @@ -88,6 +88,35 @@ end
serve()
```

## Routing Macro & Function Syntax

There are two primary ways to register your request handlers: the standard routing macros or the routing functions which utilize the do-block syntax.

For each routing macro, we now have a an equivalent routing function

```julia
@get -> get()
@post -> post()
@put -> put()
@patch -> patch()
@delete -> delete()
@route -> route()
```

The only practical difference between the two is that the routing macros are called during the precompilation
stage, whereas the routing functions are only called when invoked. (The routing macros call the routing functions under the hood)

```julia
# Routing Macro syntax
@get "/add/{x}/{y}" function(request::HTTP.Request, x::Int, y::Int)
x + y
end

# Routing Function syntax
get("/add/{x}/{y}") do request::HTTP.Request, x::Int, y::Int
x + y
end
```

## Path parameters

Expand Down
Loading

2 comments on commit f3af6c7

@ndortega
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/84840

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.9 -m "<description of version>" f3af6c7f2f6f3baf3cf83c2bc3b448198964717f
git push origin v1.1.9

Please sign in to comment.