-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4de461b
commit b09d5e0
Showing
8 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## articles | ||
- https://medium.com/@mithunmk93/algorithm-behind-splitwises-debt-simplification-feature-8ac485e97688 | ||
- https://medium.com/@howoftech/how-does-the-splitwise-algorithm-work-dc1de5eaa371 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
import app/web | ||
import gleam/string_builder | ||
import controllers/home | ||
import controllers/session | ||
import wisp.{type Request, type Response} | ||
|
||
/// The HTTP request handler- your application! | ||
/// | ||
pub fn handle_request(req: Request) -> Response { | ||
// Apply the middleware stack for this request/response. | ||
use _req <- web.middleware(req) | ||
use req <- web.middleware(req) | ||
|
||
// Later we'll use templates, but for now a string will do. | ||
let body = string_builder.from_string("<h1>Hello, Joe!</h1>") | ||
// Wisp doesn't have a special router abstraction, instead we recommend using | ||
// regular old pattern matching. This is faster than a router, is type safe, | ||
// and means you don't have to learn or be limited by a special DSL. | ||
// | ||
case wisp.path_segments(req) { | ||
// This matches `/`. | ||
[] -> home.controller(req) | ||
|
||
// Return a 200 OK response with the body and a HTML content type. | ||
wisp.html_response(body, 200) | ||
// responds to session | ||
["session"] -> session.controller(req) | ||
|
||
_ -> wisp.not_found() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import gleam/http.{Get} | ||
import gleam/string_builder | ||
import wisp.{type Request, type Response} | ||
|
||
fn show(_req: Request) -> Response { | ||
// The home page can only be accessed via GET requests, so this middleware is | ||
// used to return a 405: Method Not Allowed response for all other methods. | ||
// use <- wisp.require_method(req, Get) | ||
|
||
let html = string_builder.from_string("Welcome to Okane") | ||
|
||
wisp.ok() | ||
|> wisp.html_body(html) | ||
} | ||
|
||
pub fn controller(req: Request) -> Response { | ||
case req.method { | ||
Get -> show(req) | ||
|
||
_ -> wisp.method_not_allowed([Get]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import gleam/http.{Get} | ||
import gleam/string_builder | ||
import wisp.{type Request, type Response} | ||
|
||
fn show_user(_req: Request) -> Response { | ||
let html = string_builder.from_string("Welcome Okane") | ||
|
||
wisp.ok() | ||
|> wisp.html_body(html) | ||
} | ||
|
||
pub fn controller(req: Request) -> Response { | ||
case req.method { | ||
Get -> show_user(req) | ||
|
||
_ -> wisp.method_not_allowed([Get]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters