Clean up imports (#185)
* Clean up import declarations to only use qualified when necessary * Remove unused imports
This commit is contained in:
@@ -1,29 +1,28 @@
|
||||
module Examples.QueryParameters.Main where
|
||||
|
||||
import Prelude
|
||||
import Effect.Console as Console
|
||||
import HTTPure as HTTPure
|
||||
import HTTPure ((!@), (!?))
|
||||
import Effect.Console (log)
|
||||
import HTTPure (Request, ResponseM, ServerM, (!@), (!?), serve, ok)
|
||||
|
||||
-- | Specify the routes
|
||||
router :: HTTPure.Request -> HTTPure.ResponseM
|
||||
router :: Request -> ResponseM
|
||||
router { query }
|
||||
| query !? "foo" = HTTPure.ok "foo"
|
||||
| query !@ "bar" == "test" = HTTPure.ok "bar"
|
||||
| otherwise = HTTPure.ok $ query !@ "baz"
|
||||
| query !? "foo" = ok "foo"
|
||||
| query !@ "bar" == "test" = ok "bar"
|
||||
| otherwise = ok $ query !@ "baz"
|
||||
|
||||
-- | Boot up the server
|
||||
main :: HTTPure.ServerM
|
||||
main :: ServerM
|
||||
main =
|
||||
HTTPure.serve 8080 router do
|
||||
Console.log $ " ┌───────────────────────────────────────┐"
|
||||
Console.log $ " │ Server now up on port 8080 │"
|
||||
Console.log $ " │ │"
|
||||
Console.log $ " │ To test, run: │"
|
||||
Console.log $ " │ > curl localhost:8080?foo │"
|
||||
Console.log $ " │ # => foo │"
|
||||
Console.log $ " │ > curl localhost:8080?bar=test │"
|
||||
Console.log $ " │ # => bar │"
|
||||
Console.log $ " │ > curl localhost:8080?baz=<anything> │"
|
||||
Console.log $ " │ # => <anything> │"
|
||||
Console.log $ " └───────────────────────────────────────┘"
|
||||
serve 8080 router do
|
||||
log " ┌───────────────────────────────────────┐"
|
||||
log " │ Server now up on port 8080 │"
|
||||
log " │ │"
|
||||
log " │ To test, run: │"
|
||||
log " │ > curl localhost:8080?foo │"
|
||||
log " │ # => foo │"
|
||||
log " │ > curl localhost:8080?bar=test │"
|
||||
log " │ # => bar │"
|
||||
log " │ > curl localhost:8080?baz=<anything> │"
|
||||
log " │ # => <anything> │"
|
||||
log " └───────────────────────────────────────┘"
|
||||
|
||||
Reference in New Issue
Block a user