Genie.Requests.jsonpayload - Function
jsonpayload()

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

source

jsonpayload(v)

Processes an application/json POST request attempting to return value corresponding to key v.

source


Genie.Requests.rawpayload - Function
rawpayload() :: String

Returns the raw POST payload as a String.

source


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

Collection of form uploaded files.

source

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

Returns the HttpFile uploaded through the key input name.

source


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

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

source


Base.write - Function
write(io::IO, 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.read - Function
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 (see also readchomp).

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)

Read the entire contents of a file as a Vector{UInt8}.

read(filename::AbstractString, String)

Read the entire contents of a file as a string.

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).

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(stream::IO, [nb::Integer,] enc::Encoding)
read(filename::AbstractString, [nb::Integer,] enc::Encoding)
read(stream::IO, ::Type{String}, enc::Encoding)
read(filename::AbstractString, ::Type{String}, enc::Encoding)

Methods to read text in character encoding enc. See documentation for corresponding methods without the enc argument for details.

source

read(file::HttpFile)

Returns the content of file as string.

source


Genie.Requests.filename - Function
filename(file::HttpFile) :: String

Original filename of the uploaded HttpFile file.

source


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

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

source

postpayload(key::Symbol) :: Any

Returns the value of the POST variables key.

source

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

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

source


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

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

source

getpayload(key::Symbol) :: Any

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

source

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.

source


Genie.Requests.request - Function
request() :: HTTP.Request

Returns the raw HTTP.Request object associated with the request. If no request is available (not within a request/response cycle) returns nothing.

source


Genie.Requests.payload - Function
payload() :: Any

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

source

payload(key::Symbol) :: Any

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

source

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.

source


Genie.Requests.matchedroute - Function
matchedroute() :: Route

Returns the Route object which was matched for the current request or noting if no route is available.

source


Genie.Requests.matchedchannel - Function
matchedchannel() :: Channel

Returns the Channel object which was matched for the current request or nothing if no channel is available.

source


Genie.Requests.wsclient - Function
wsclient() :: HTTP.WebSockets.WebSocket

The web sockets client for the current request or nothing if not available.

source



Genie