Genie.Requests.jsonpayloadFunction
jsonpayload()

Processes an application/jsonPOST request. If it fails to successfully parse the JSON data it returns nothing. The original payload can still be accessed invoking rawpayload()

jsonpayload(::Type{T}) where {T}

Processes an application/jsonPOST request attempting to convert the payload into a value of type T. If it fails to successfully parse and convert the JSON data, it throws an exception. The original payload can still be accessed invoking rawpayload()

Genie.Requests.filespayloadFunction
filespayload() :: Dict{String,HttpFile}

Collection of form uploaded files.

filespayload(filename::Union{String,Symbol}) :: HttpFile

Returns the HttpFile uploaded through the key input name.

Genie.Requests.infilespayloadFunction
infilespayload(key::Union{String,Symbol}) :: Bool

Checks if the collection of uploaded files contains a file stored under the key name.

Base.writeFunction
write(io::IO, x)
write(filename::AbstractString, x)

Write the canonical binary representation of a value to the given I/O stream or file. Return the number of bytes written into the stream. See also print to write a text representation (with an encoding that may depend upon io).

The endianness of the written value depends on the endianness of the host system. Convert to/from a fixed endianness when writing/reading (e.g. using htol and ltoh) to get results that are consistent across platforms.

You can write multiple values with the same write call. i.e. the following are equivalent:

write(io, x, y...)
write(io, x) + write(io, y...)

Examples

Consistent serialization:

julia> fname = tempname(); # random temporary filename

julia> open(fname,"w") do f
           # Make sure we write 64bit integer in little-endian byte order
           write(f,htol(Int64(42)))
       end
8

julia> open(fname,"r") do f
           # Convert back to host byte order and host integer type
           Int(ltoh(read(f,Int64)))
       end
42

Merging write calls:

julia> io = IOBuffer();

julia> write(io, "JuliaLang is a GitHub organization.", " It has many members.")
56

julia> String(take!(io))
"JuliaLang is a GitHub organization. It has many members."

julia> write(io, "Sometimes those members") + write(io, " write documentation.")
44

julia> String(take!(io))
"Sometimes those members write documentation."

User-defined plain-data types without write methods can be written when wrapped in a Ref:

julia> struct MyStruct; x::Float64; end

julia> io = IOBuffer()
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)

julia> write(io, Ref(MyStruct(42.0)))
8

julia> seekstart(io); read!(io, Ref(MyStruct(NaN)))
Base.RefValue{MyStruct}(MyStruct(42.0))
source
Base.readFunction
read(io::IO, T)

Read a single value of type T from io, in canonical binary representation.

Note that Julia does not convert the endianness for you. Use ntoh or ltoh for this purpose.

read(io::IO, String)

Read the entirety of io, as a String.

Examples

julia> io = IOBuffer("JuliaLang is a GitHub organization");

julia> read(io, Char)
'J': ASCII/Unicode U+004A (category Lu: Letter, uppercase)

julia> io = IOBuffer("JuliaLang is a GitHub organization");

julia> read(io, String)
"JuliaLang is a GitHub organization"
source
read(filename::AbstractString, args...)

Open a file and read its contents. args is passed to read: this is equivalent to open(io->read(io, args...), filename).

read(filename::AbstractString, String)

Read the entire contents of a file as a string.

source
read(s::IO, nb=typemax(Int))

Read at most nb bytes from s, returning a Vector{UInt8} of the bytes read.

source
read(s::IOStream, nb::Integer; all=true)

Read at most nb bytes from s, returning a Vector{UInt8} of the bytes read.

If all is true (the default), this function will block repeatedly trying to read all requested bytes, until an error or end-of-file occurs. If all is false, at most one read call is performed, and the amount of data returned is device-dependent. Note that not all stream types support the all option.

source
read(command::Cmd)

Run command and return the resulting output as an array of bytes.

source
read(command::Cmd, String)

Run command and return the resulting output as a String.

source
read(file::HttpFile)

Returns the content of file as string.

Genie.Requests.filenameFunction
filename(file::HttpFile) :: String

Original filename of the uploaded HttpFilefile.

Genie.Requests.postpayloadFunction
postpayload() :: Dict{Symbol,Any}

A dict representing the POST variables payload of the request (corresponding to a form-data request)

postpayload(key::Symbol) :: Any

Returns the value of the POST variables key.

postpayload(key::Symbol, default::Any)

Returns the value of the POST variables key or the default value if key is not defined.

Genie.Requests.getpayloadFunction
getpayload() :: Dict{Symbol,Any}

A dict representing the GET/query variables payload of the request (the part correspoding to ?foo=bar&baz=moo)

getpayload(key::Symbol) :: Any

The value of the GET/query variable key, as in ?key=value

getpayload(key::Symbol, default::Any) :: Any

The value of the GET/query variable key, as in ?key=value. If key is not defined, default is returned.

Genie.Requests.requestFunction
request() :: HTTP.Request

Returns the raw HTTP.Request object associated with the request.

Genie.Requests.payloadFunction
payload() :: Any

Utility function for accessing the @params collection, which holds the request variables.

payload(key::Symbol) :: Any

Utility function for accessing the key value within the @params collection of request variables.

payload(key::Symbol, default_value::T) :: Any

Utility function for accessing the key value within the @params collection of request variables. If key is not defined, default_value is returned.

Genie.Requests.wsclientFunction
wsclient() :: HTTP.WebSockets.WebSocket

The web sockets client for the current request.