🧚 A practical web framework for Gleam

Update comments

+18 -12
+6 -10
src/wisp.gleam
··· 126 126 HttpResponse(status, [], Empty) 127 127 } 128 128 129 + // TODO: test 130 + // TODO: document 129 131 pub fn set_body(response: Response, body: ResponseBody) -> Response { 130 132 response 131 133 |> response.set_body(body) ··· 353 355 // TODO: don't always return entity to large. Other errors are possible, such as 354 356 // network errors. 355 357 // TODO: document 358 + // TODO: note you probably want a `require_` function 359 + // TODO: note it'll hang if you call it twice 360 + // TODO: note it respects the max body size 356 361 pub fn require_string_body( 357 362 request: Request, 358 363 next: fn(String) -> Response, ··· 363 368 } 364 369 } 365 370 366 - // TODO: test 367 - // TODO: public? 368 - // TODO: document 369 - // TODO: note you probably want a `require_` function 370 - // TODO: note it'll hang if you call it twice 371 - // TODO: note it respects the max body size 371 + // Should we make this public? 372 372 fn read_entire_body(request: Request) -> Result(BitString, Nil) { 373 373 let connection = request.body 374 374 read_body_loop( ··· 802 802 } 803 803 } 804 804 805 - // TODO: test 806 805 // TODO: document 807 - // TODO: remove requirement for preceeding slash on prefix 808 806 pub fn serve_static( 809 807 req: Request, 810 808 under prefix: String, ··· 819 817 path 820 818 |> string.drop_left(string.length(prefix)) 821 819 |> string.replace(each: "..", with: "") 822 - |> string.replace(each: "//", with: "/") 823 - |> remove_preceeding_slashes 824 820 |> join_path(directory, _) 825 821 826 822 let mime_type =
+12 -2
test/wisp_test.gleam
··· 275 275 |> should.equal(wisp.File("./README.md")) 276 276 } 277 277 278 - pub fn serve_static_under_has_no_preceeding_slash_test() { 278 + pub fn serve_static_under_has_no_trailing_slash_test() { 279 279 let request = 280 280 wisp.test_request(<<>>) 281 281 |> request.set_path("/stuff/README.md") ··· 317 317 } 318 318 |> should.equal(wisp.ok()) 319 319 } 320 - // TODO: More tests for serve_static! 320 + 321 + pub fn serve_static_go_up_test() { 322 + let request = 323 + wisp.test_request(<<>>) 324 + |> request.set_path("/../README.md") 325 + { 326 + use <- wisp.serve_static(request, under: "/stuff", from: "./src/") 327 + wisp.ok() 328 + } 329 + |> should.equal(wisp.ok()) 330 + }