Skip to content

Commit 12640ae

Browse files
author
Ryan Miville
committed
no wisp
1 parent 0905488 commit 12640ae

File tree

12 files changed

+67
-86
lines changed

12 files changed

+67
-86
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Write AWS Lambda functions in Gleam!
55
[![Package Version](https://img.shields.io/hexpm/v/glambda)](https://hex.pm/packages/glambda)
66
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/glambda/)
77

8-
Write your Lambda function as a [wisp](https://github.com/gleam-wisp/wisp) handler, or accept direct events as normal Gleam types.
8+
Write your Lambda function as an [http](https://github.com/gleam-lang/http) handler, or accept direct events as normal Gleam types.
99

1010
Glambda works by compiling your Gleam code to JavaScript, and then using the AWS Lambda Node.js runtime to run your code.
1111

@@ -17,20 +17,26 @@ gleam add glambda
1717

1818
```gleam
1919
import glambda.{type Context}
20+
import gleam/http/request.{type Request}
21+
import gleam/http/response.{type Response, Response}
2022
import gleam/javascript/promise.{type Promise}
21-
import gleam/string_builder
22-
import wisp.{type Request, type Response}
23+
import gleam/option.{type Option, Some}
2324
24-
fn handle_request(_req: Request, ctx: Context) -> Promise(Response) {
25-
string_builder.from_string(
26-
"{\"functionName\": \"" <> ctx.function_name <> "\"}",
25+
fn handle_request(
26+
_req: Request(Option(String)),
27+
ctx: Context,
28+
) -> Promise(Response(Option(String))) {
29+
let json = "{\"functionName\": \"" <> ctx.function_name <> "\"}"
30+
Response(
31+
200,
32+
[#("content-type", "application/json; charset=utf-8")],
33+
Some(json),
2734
)
28-
|> wisp.json_response(200)
2935
|> promise.resolve
3036
}
3137
3238
pub fn handler(event, ctx) {
33-
glambda.wisp_handler(handle_request)(event, ctx)
39+
glambda.http_handler(handle_request)(event, ctx)
3440
}
3541
```
3642

examples/app/src/handler.gleam

Lines changed: 0 additions & 16 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

examples/app/gleam.toml renamed to examples/simple/gleam.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ target = "javascript"
55
[dependencies]
66
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
77
glambda = { path = "../.." }
8-
wisp = ">= 1.2.0 and < 2.0.0"
98
gleam_http = ">= 3.7.0 and < 4.0.0"
109
gleam_javascript = ">= 0.13.0 and < 1.0.0"
1110

examples/app/manifest.toml renamed to examples/simple/manifest.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages = [
77
{ name = "envoy", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "CFAACCCFC47654F7E8B75E614746ED924C65BD08B1DE21101548AC314A8B6A41" },
88
{ name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" },
99
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
10-
{ name = "glambda", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib", "wisp"], source = "local", path = "../.." },
10+
{ name = "glambda", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], source = "local", path = "../.." },
1111
{ name = "gleam_crypto", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "8AE56026B3E05EBB1F076778478A762E9EB62B31AEEB4285755452F397029D22" },
1212
{ name = "gleam_erlang", version = "0.27.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "DE468F676D71B313C6C8C5334425CFCF827837333F8AB47B64D8A6D7AA40185D" },
1313
{ name = "gleam_http", version = "3.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "EA66440C2269F7CED0F6845E5BD0DB68095775D627FA709A841CA78A398D6D56" },
@@ -35,4 +35,3 @@ gleam_http = { version = ">= 3.7.0 and < 4.0.0" }
3535
gleam_javascript = { version = ">= 0.13.0 and < 1.0.0" }
3636
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
3737
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
38-
wisp = { version = ">= 1.2.0 and < 2.0.0" }

examples/simple/src/handler.gleam

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import glambda.{type Context}
2+
import gleam/http/request.{type Request}
3+
import gleam/http/response.{type Response, Response}
4+
import gleam/javascript/promise.{type Promise}
5+
import gleam/option.{type Option, Some}
6+
7+
pub fn handle_request(
8+
_req: Request(Option(String)),
9+
ctx: Context,
10+
) -> Promise(Response(Option(String))) {
11+
let json = "{\"functionName\": \"" <> ctx.function_name <> "\"}"
12+
Response(
13+
200,
14+
[#("content-type", "application/json; charset=utf-8")],
15+
Some(json),
16+
)
17+
|> promise.resolve
18+
}
19+
20+
pub fn handler(event, ctx) {
21+
glambda.http_handler(handle_request)(event, ctx)
22+
}

gleam.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ target = "javascript"
1818
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
1919
gleam_javascript = ">= 0.13.0 and < 1.0.0"
2020
gleam_http = ">= 3.7.0 and < 4.0.0"
21-
wisp = ">= 1.2.0 and < 2.0.0"
2221

2322
[dev-dependencies]
2423
gleeunit = ">= 1.0.0 and < 2.0.0"

0 commit comments

Comments
 (0)