helper for status codes
This commit is contained in:
parent
0f587b3464
commit
ba05db91fe
|
@ -8,15 +8,7 @@ include("types.jl")
|
|||
|
||||
include("server.jl")
|
||||
|
||||
import Base.write
|
||||
write(c::Connection, data::Vector{UInt8}) = OpenSSL.write(c.client, data)
|
||||
function write(conn::Connection, s::Status)
|
||||
write(conn.client,
|
||||
string(s.major, s.minor, ' ', s.meta, '\r', '\n'))
|
||||
end
|
||||
function write(conn::Connection, r::Response)
|
||||
write(conn, r.status)
|
||||
write(conn.client, r.body)
|
||||
end
|
||||
include("rw.jl")
|
||||
export link, document, status, not_found
|
||||
|
||||
end # module
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import Base.write
|
||||
write(c::Connection, data::Vector{UInt8}) = OpenSSL.write(c.client, data)
|
||||
function write(conn::Connection, s::Status)
|
||||
write(conn.client,
|
||||
string(s.major, s.minor, ' ', s.meta, '\r', '\n'))
|
||||
end
|
||||
function write(conn::Connection, r::Response)
|
||||
write(conn, r.status)
|
||||
write(conn.client, r.body)
|
||||
end
|
||||
|
||||
status(conn::Connection, s...) = write(conn, Status(s...))
|
||||
not_found(conn::Connection, meta = "Not Found") = status(conn, 51, meta)
|
||||
document(conn::Connection, body) =
|
||||
write(conn, Response(Status(20, "text/gemini"), body))
|
||||
link(dst, name = dst) = string("=> ", dst, " ", name)
|
Loading…
Reference in New Issue