🧚 A practical web framework for Gleam

Use the directories package to detect a temp directory

authored by DitherWither and committed by Louis Pilfold 9d7635a8 1693073c

+1
CHANGELOG.md
··· 5 5 - The Mist web server related functions have been moved to the `wisp_mist` 6 6 module. 7 7 - The `wisp` module gains the `set_logger_level` function and `LogLevel` type. 8 + - Rather than using `/tmp`, the platform-specific temporary directory is detected used 8 9 9 10 ## v0.16.0 - 2024-07-13 10 11
+1
gleam.toml
··· 18 18 simplifile = ">= 2.0.0 and < 3.0.0" 19 19 marceau = ">= 1.1.0 and < 2.0.0" 20 20 logging = ">= 1.2.0 and < 2.0.0" 21 + directories = ">= 1.0.0 and < 2.0.0" 21 22 22 23 [dev-dependencies] 23 24 gleeunit = "~> 1.0"
+3
manifest.toml
··· 3 3 4 4 packages = [ 5 5 { name = "birl", version = "1.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "5C66647D62BCB11FE327E7A6024907C4A17954EF22865FE0940B54A852446D01" }, 6 + { name = "directories", version = "1.0.0", build_tools = ["gleam"], requirements = ["envoy", "gleam_erlang", "gleam_stdlib", "simplifile"], otp_app = "directories", source = "hex", outer_checksum = "8691C1581C6D8FB7EF390127B096B308D2ED05BCA90468B1D1218DE5AB5C4B04" }, 7 + { name = "envoy", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "CFAACCCFC47654F7E8B75E614746ED924C65BD08B1DE21101548AC314A8B6A41" }, 6 8 { name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" }, 7 9 { name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" }, 8 10 { name = "gleam_crypto", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "ADD058DEDE8F0341F1ADE3AAC492A224F15700829D9A3A3F9ADF370F875C51B7" }, ··· 25 27 ] 26 28 27 29 [requirements] 30 + directories = { version = ">= 1.0.0 and < 2.0.0" } 28 31 exception = { version = ">= 2.0.0 and < 3.0.0" } 29 32 gleam_crypto = { version = ">= 1.0.0 and < 2.0.0" } 30 33 gleam_erlang = { version = ">= 0.21.0 and < 2.0.0" }
+4 -2
src/wisp/internal.gleam
··· 1 + import directories 1 2 import gleam/bit_array 2 3 import gleam/crypto 4 + import gleam/result 3 5 import gleam/string 4 6 5 7 // HELPERS ··· 28 30 body_reader: Reader, 29 31 secret_key_base: String, 30 32 ) -> Connection { 31 - // TODO: replace `/tmp` with appropriate for the OS 32 - let prefix = "/tmp/gleam-wisp/" 33 + // Fallback to current working directory when no valid tmp directory exists 34 + let prefix = result.unwrap(directories.tmp_dir(), ".") <> "/gleam-wisp/" 33 35 let temporary_directory = join_path(prefix, random_slug()) 34 36 Connection( 35 37 reader: body_reader,