Apply type annotations to path parameters
masterOxygen uses standard Julia type annotations in your request handler to automatically convert incoming path parameter strings into the specified types.
- With annotations: Oxygen attempts to convert the data automatically. If the conversion fails, the route will not match or will error.
- Without annotations: Oxygen treats the parameter as a
Stringby default. You must manually parse the value using functions likeparse().
# Automatic conversion using type annotations
@get "/multiply/{a}/{b}" function(req, a::Float64, b::Float64)
return a * b
end
# Manual conversion without type annotations
@get "/multiply/{a}/{b}" function(req, a, b)
return parse(Float64, a) * parse(Float64, b)
end