Skip to content

Commit

Permalink
feat: add {Request,Response} getters (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Mar 3, 2024
1 parent 3870acb commit be29312
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/piaf.mli
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ module Request : sig
; body : Body.t
}

val meth : t -> Method.t
val target : t -> string
val version : t -> Versions.HTTP.t
val headers : t -> Headers.t
val scheme : t -> Scheme.t
val body : t -> Body.t

val create :
scheme:Scheme.t
-> version:Versions.HTTP.t
Expand Down Expand Up @@ -496,6 +503,11 @@ module Response : sig
; body : Body.t
}

val status : t -> Status.t
val headers : t -> Headers.t
val version : t -> Versions.HTTP.t
val body : t -> Body.t

val create :
?version:Versions.HTTP.t
-> ?headers:Headers.t
Expand Down
7 changes: 7 additions & 0 deletions lib/request.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type t =
; body : Body.t
}

let meth { meth; _ } = meth
let target { target; _ } = target
let version { version; _ } = version
let headers { headers; _ } = headers
let scheme { scheme; _ } = scheme
let body { body; _ } = body

let uri { scheme; target; headers; version; _ } =
let uri =
let scheme = Scheme.to_string scheme in
Expand Down
5 changes: 5 additions & 0 deletions lib/response.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ type t =
; body : Body.t
}

let status { status; _ } = status
let headers { headers; _ } = headers
let version { version; _ } = version
let body { body; _ } = body

(* TODO: Add content-length... *)
let create
?(version = Versions.HTTP.HTTP_1_1)
Expand Down

0 comments on commit be29312

Please sign in to comment.