feat: add Response_code.is_success

This commit is contained in:
Simon Cruanes 2024-01-24 13:11:47 -05:00
parent ce00f7a027
commit df8b579d24
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 6 additions and 0 deletions

View file

@ -42,6 +42,8 @@ module Response_code = struct
| 501 -> "Not implemented"
| 503 -> "Service unavailable"
| n -> "Unknown response code " ^ string_of_int n (* TODO *)
let[@inline] is_success n = n >= 200 && n < 400
end
type 'a resp_result = ('a, Response_code.t * string) result

View file

@ -195,6 +195,10 @@ module Response_code : sig
val descr : t -> string
(** A description of some of the error codes.
NOTE: this is not complete (yet). *)
val is_success : t -> bool
(** [is_success code] is true iff [code] is in the [2xx] or [3xx] range.
@since NEXT_RELEASE *)
end
(** {2 Responses}