Skip to content

Commit eca2058

Browse files
yoshi-monsterlpil
authored andcommitted
fix deprecation warnings for result.then
1 parent 4c9849a commit eca2058

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/gleam/http/cookie.gleam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ pub fn parse(cookie_string: String) -> List(#(String, String)) {
105105
Ok(#(key, value)) -> {
106106
let key = string.trim(key)
107107
let value = string.trim(value)
108-
use _ <- result.then(check_token(key))
109-
use _ <- result.then(check_token(value))
108+
use _ <- result.try(check_token(key))
109+
use _ <- result.try(check_token(value))
110110
Ok(#(key, value))
111111
}
112112
Error(Nil) -> Error(Nil)

src/gleam/http/request.gleam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import gleam/uri.{type Uri, Uri}
1010
///
1111
/// The body of the request is parameterised. The HTTP server or client you are
1212
/// using will have a particular set of types it supports for the body.
13-
///
13+
///
1414
pub type Request(body) {
1515
Request(
1616
method: Method,
@@ -42,12 +42,12 @@ pub fn to_uri(request: Request(a)) -> Uri {
4242
/// Construct a request from a URI.
4343
///
4444
pub fn from_uri(uri: Uri) -> Result(Request(String), Nil) {
45-
use scheme <- result.then(
45+
use scheme <- result.try(
4646
uri.scheme
4747
|> option.unwrap("")
4848
|> http.scheme_from_string,
4949
)
50-
use host <- result.then(
50+
use host <- result.try(
5151
uri.host
5252
|> option.to_result(Nil),
5353
)
@@ -216,7 +216,7 @@ pub fn new() -> Request(String) {
216216
pub fn to(url: String) -> Result(Request(String), Nil) {
217217
url
218218
|> uri.parse
219-
|> result.then(from_uri)
219+
|> result.try(from_uri)
220220
}
221221

222222
/// Set the scheme (protocol) of the request.

src/gleam/http/response.gleam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import gleam/string
99
///
1010
/// The body of the request is parameterised. The HTTP server or client you are
1111
/// using will have a particular set of types it supports for the body.
12-
///
12+
///
1313
pub type Response(body) {
1414
Response(
1515
status: Int,
@@ -28,7 +28,7 @@ pub fn try_map(
2828
response: Response(old_body),
2929
transform: fn(old_body) -> Result(new_body, error),
3030
) -> Result(Response(new_body), error) {
31-
use body <- result.then(transform(response.body))
31+
use body <- result.try(transform(response.body))
3232
Ok(set_body(response, body))
3333
}
3434

@@ -113,7 +113,7 @@ pub fn redirect(uri: String) -> Response(String) {
113113
)
114114
}
115115

116-
/// Fetch the cookies sent in a response.
116+
/// Fetch the cookies sent in a response.
117117
///
118118
/// Badly formed cookies will be discarded.
119119
///

src/gleam/http/service.gleam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ fn ensure_post(req: Request(a)) {
3939
}
4040

4141
fn get_override_method(request: Request(t)) -> Result(http.Method, Nil) {
42-
use query_params <- result.then(request.get_query(request))
43-
use method <- result.then(list.key_find(query_params, "_method"))
44-
use method <- result.then(http.parse_method(method))
42+
use query_params <- result.try(request.get_query(request))
43+
use method <- result.try(list.key_find(query_params, "_method"))
44+
use method <- result.try(http.parse_method(method))
4545
case method {
4646
Put | Patch | Delete -> Ok(method)
4747
_ -> Error(Nil)
@@ -53,7 +53,7 @@ pub fn method_override(service) {
5353
fn(request) {
5454
request
5555
|> ensure_post
56-
|> result.then(get_override_method)
56+
|> result.try(get_override_method)
5757
|> result.map(request.set_method(request, _))
5858
|> result.unwrap(request)
5959
|> service

0 commit comments

Comments
 (0)