Skip to content

Commit 286b7bb

Browse files
ryuheechullpil
authored andcommitted
Compromise the functional style to enhance readability
1 parent a0a0bda commit 286b7bb

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
.PHONY: format-check
2-
format-check:
1+
.PHONY: test
2+
test: check-format
3+
gleam test
4+
5+
.PHONY: check-format
6+
check-format:
37
gleam format --check src test
48

59
.PHONY: format

src/echo/web/logger.gleam

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import gleam/int
66
import gleam/io
77
import gleam/string
88
import gleam/string_builder
9-
import gleam/function
109

1110
fn format_log_line(request: Request(a), response: Response(b)) -> String {
1211
request.method
@@ -22,11 +21,9 @@ fn format_log_line(request: Request(a), response: Response(b)) -> String {
2221

2322
pub fn middleware(service: Service(a, b)) -> Service(a, b) {
2423
fn(request) {
25-
service(request)
26-
|> function.tap(fn(response) {
27-
response
28-
|> format_log_line(request, _)
29-
|> io.println
30-
})
24+
let response = service(request)
25+
format_log_line(request, response)
26+
|> io.println
27+
response
3128
}
3229
}

0 commit comments

Comments
 (0)