|
| 1 | +class Goshs < Formula |
| 2 | + desc "Simple, yet feature-rich web server written in Go" |
| 3 | + homepage "https://goshs.de/en/index.html" |
| 4 | + url "https://github.com/patrickhener/goshs/archive/refs/tags/v1.0.8.tar.gz" |
| 5 | + sha256 "ee755ea7355eb6264e097c80c04d8a7affb091b4c732b102c685e762374f2f68" |
| 6 | + license "MIT" |
| 7 | + head "https://github.com/patrickhener/goshs.git", branch: "main" |
| 8 | + |
| 9 | + bottle do |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "2aa7632d01f991f5155d1a8cace4020bffcef199adc9c768d59c4074d4359d9c" |
| 11 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "2aa7632d01f991f5155d1a8cace4020bffcef199adc9c768d59c4074d4359d9c" |
| 12 | + sha256 cellar: :any_skip_relocation, arm64_ventura: "2aa7632d01f991f5155d1a8cace4020bffcef199adc9c768d59c4074d4359d9c" |
| 13 | + sha256 cellar: :any_skip_relocation, sonoma: "7c5a9a91e9529df0afd5df46aacf4ebd7dc408cef63f0b94d48cd1604a397108" |
| 14 | + sha256 cellar: :any_skip_relocation, ventura: "7c5a9a91e9529df0afd5df46aacf4ebd7dc408cef63f0b94d48cd1604a397108" |
| 15 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "bb22983ed9ad12e9395b1683a49bead9de1ece58facc2fe281944eb9fdd0c610" |
| 16 | + end |
| 17 | + |
| 18 | + depends_on "go" => :build |
| 19 | + |
| 20 | + def install |
| 21 | + system "go", "build", *std_go_args(ldflags: "-s -w") |
| 22 | + end |
| 23 | + |
| 24 | + test do |
| 25 | + assert_match version.to_s, shell_output("#{bin}/goshs -v") |
| 26 | + |
| 27 | + (testpath/"test.txt").write "Hello, Goshs!" |
| 28 | + |
| 29 | + port = free_port |
| 30 | + server_pid = spawn bin/"goshs", "-p", port.to_s, "-d", testpath, "-si" |
| 31 | + sleep 2 |
| 32 | + output = shell_output("curl -s http://localhost:#{port}/test.txt") |
| 33 | + assert_match "Hello, Goshs!", output |
| 34 | + ensure |
| 35 | + Process.kill("TERM", server_pid) |
| 36 | + Process.wait(server_pid) |
| 37 | + end |
| 38 | +end |
0 commit comments