mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 19:25:32 -05:00
feat: add Response_code.is_success
This commit is contained in:
parent
ce00f7a027
commit
df8b579d24
2 changed files with 6 additions and 0 deletions
|
|
@ -42,6 +42,8 @@ module Response_code = struct
|
||||||
| 501 -> "Not implemented"
|
| 501 -> "Not implemented"
|
||||||
| 503 -> "Service unavailable"
|
| 503 -> "Service unavailable"
|
||||||
| n -> "Unknown response code " ^ string_of_int n (* TODO *)
|
| n -> "Unknown response code " ^ string_of_int n (* TODO *)
|
||||||
|
|
||||||
|
let[@inline] is_success n = n >= 200 && n < 400
|
||||||
end
|
end
|
||||||
|
|
||||||
type 'a resp_result = ('a, Response_code.t * string) result
|
type 'a resp_result = ('a, Response_code.t * string) result
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,10 @@ module Response_code : sig
|
||||||
val descr : t -> string
|
val descr : t -> string
|
||||||
(** A description of some of the error codes.
|
(** A description of some of the error codes.
|
||||||
NOTE: this is not complete (yet). *)
|
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
|
end
|
||||||
|
|
||||||
(** {2 Responses}
|
(** {2 Responses}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue