๐Ÿ‘ฉโ€๐Ÿš’ Firefighters API written in Gleam!
lustre gleam

:construction: handle `not found`

kacaii.dev 9a6de528 468a2b8a

verified
+15 -33
-24
client/README.md
··· 1 - # client 2 - 3 - [![Package Version](https://img.shields.io/hexpm/v/client)](https://hex.pm/packages/client) 4 - [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/client/) 5 - 6 - ```sh 7 - gleam add client@1 8 - ``` 9 - ```gleam 10 - import client 11 - 12 - pub fn main() -> Nil { 13 - // TODO: An example of the project in use 14 - } 15 - ``` 16 - 17 - Further documentation can be found at <https://hexdocs.pm/client>. 18 - 19 - ## Development 20 - 21 - ```sh 22 - gleam run # Run the project 23 - gleam test # Run the tests 24 - ```
client/assets/style.css

This is a binary file and will not be displayed.

+4 -1
client/gleam.toml
··· 19 19 20 20 [tools.lustre.dev] 21 21 host = "0.0.0.0" 22 - proxy = { from = "/api", to = "http://localhost:8000" } 22 + port = 3000 23 + proxy = { from = "/api", to = "http://localhost:8000/api" } 24 + stylesheets = [{ href = "/style.css" }] 25 + title = "SIGO"
+11 -8
server/src/server/router.gleam
··· 1 1 import server/context.{type Context} 2 2 import wisp.{type Request, type Response} 3 3 4 + pub fn handle_request(req: Request, ctx: Context) -> Response { 5 + use req <- middleware(req, ctx) 6 + 7 + case wisp.path_segments(req) { 8 + [] -> wisp.ok() 9 + _ -> wisp.not_found() 10 + } 11 + } 12 + 4 13 fn middleware( 5 14 req: Request, 6 15 ctx: Context, 7 - handler: fn(wisp.Request) -> Response, 16 + next: fn(wisp.Request) -> Response, 8 17 ) -> Response { 9 18 let req = wisp.method_override(req) 10 - 11 19 use <- wisp.log_request(req) 12 20 use <- wisp.rescue_crashes() 13 21 use req <- wisp.handle_head(req) 14 22 use req <- wisp.csrf_known_header_protection(req) 15 23 use <- wisp.serve_static(req, "/static", ctx.priv) 16 24 17 - handler(req) 18 - } 19 - 20 - pub fn handle_request(req: Request, ctx: Context) -> Response { 21 - use _req <- middleware(req, ctx) 22 - wisp.ok() 25 + next(req) 23 26 }