├── .gitignore ├── LICENSE ├── README.md ├── netlify.toml ├── netlify └── functions │ └── hello │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ └── main.rs └── public └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .netlify 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Netlify 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | This example shows how to deploy Rust code on Netlify Functions. 4 | 5 | Functions can be deployed using [Netlify's CLI](https://ntl.fyi/cli) as well as the Netlify Build environment. 6 | 7 | You can copy this repository and deploy it to Netlify by clicking the button below. 8 | 9 | Deploy to Netlify 10 | 11 | After clicking that button, you’ll authenticate with GitHub and choose a repository name. Netlify will then automatically create a repository in your GitHub account with a copy of the files from the template. Next, it will build and deploy the new site on Netlify, bringing you to the site dashboard when the build is complete. 12 | 13 | ## Build & Deployment 14 | 15 | ### Deploying with CLI 16 | 17 | You need to install Netlify's CLI first: 18 | 19 | ``` 20 | npm install -g netlify-cli 21 | ``` 22 | 23 | Then run the following command: 24 | 25 | ``` 26 | netlify deploy --build 27 | ``` 28 | 29 | ### Deploying with Netlify Build 30 | 31 | Create a new Netlify site and link it to your repository. Netlify will detect the Rust functions automatically, build and deploy them for you. 32 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [context.production] 2 | environment = { NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE = "true" } 3 | -------------------------------------------------------------------------------- /netlify/functions/hello/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /netlify/functions/hello/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "async-stream" 7 | version = "0.3.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625" 10 | dependencies = [ 11 | "async-stream-impl", 12 | "futures-core", 13 | ] 14 | 15 | [[package]] 16 | name = "async-stream-impl" 17 | version = "0.3.2" 18 | source = "registry+https://github.com/rust-lang/crates.io-index" 19 | checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" 20 | dependencies = [ 21 | "proc-macro2", 22 | "quote", 23 | "syn", 24 | ] 25 | 26 | [[package]] 27 | name = "atty" 28 | version = "0.2.14" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 31 | dependencies = [ 32 | "hermit-abi", 33 | "libc", 34 | "winapi", 35 | ] 36 | 37 | [[package]] 38 | name = "autocfg" 39 | version = "1.0.1" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 42 | 43 | [[package]] 44 | name = "aws_lambda_events" 45 | version = "0.4.0" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "663ef110325f68726f4bc51d12c610b9700f70e8bb8a55279cdeca01b12b5491" 48 | dependencies = [ 49 | "base64", 50 | "bytes 0.5.6", 51 | "chrono", 52 | "http", 53 | "http-serde", 54 | "serde", 55 | "serde_derive", 56 | "serde_json", 57 | ] 58 | 59 | [[package]] 60 | name = "base64" 61 | version = "0.12.3" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" 64 | 65 | [[package]] 66 | name = "bytes" 67 | version = "0.5.6" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" 70 | dependencies = [ 71 | "serde", 72 | ] 73 | 74 | [[package]] 75 | name = "bytes" 76 | version = "1.0.1" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" 79 | 80 | [[package]] 81 | name = "cfg-if" 82 | version = "1.0.0" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 85 | 86 | [[package]] 87 | name = "chrono" 88 | version = "0.4.19" 89 | source = "registry+https://github.com/rust-lang/crates.io-index" 90 | checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" 91 | dependencies = [ 92 | "libc", 93 | "num-integer", 94 | "num-traits", 95 | "serde", 96 | "time", 97 | "winapi", 98 | ] 99 | 100 | [[package]] 101 | name = "colored" 102 | version = "1.9.3" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" 105 | dependencies = [ 106 | "atty", 107 | "lazy_static", 108 | "winapi", 109 | ] 110 | 111 | [[package]] 112 | name = "fnv" 113 | version = "1.0.7" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 116 | 117 | [[package]] 118 | name = "futures" 119 | version = "0.3.15" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27" 122 | dependencies = [ 123 | "futures-channel", 124 | "futures-core", 125 | "futures-executor", 126 | "futures-io", 127 | "futures-sink", 128 | "futures-task", 129 | "futures-util", 130 | ] 131 | 132 | [[package]] 133 | name = "futures-channel" 134 | version = "0.3.15" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2" 137 | dependencies = [ 138 | "futures-core", 139 | "futures-sink", 140 | ] 141 | 142 | [[package]] 143 | name = "futures-core" 144 | version = "0.3.15" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" 147 | 148 | [[package]] 149 | name = "futures-executor" 150 | version = "0.3.15" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "badaa6a909fac9e7236d0620a2f57f7664640c56575b71a7552fbd68deafab79" 153 | dependencies = [ 154 | "futures-core", 155 | "futures-task", 156 | "futures-util", 157 | ] 158 | 159 | [[package]] 160 | name = "futures-io" 161 | version = "0.3.15" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" 164 | 165 | [[package]] 166 | name = "futures-macro" 167 | version = "0.3.15" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" 170 | dependencies = [ 171 | "autocfg", 172 | "proc-macro-hack", 173 | "proc-macro2", 174 | "quote", 175 | "syn", 176 | ] 177 | 178 | [[package]] 179 | name = "futures-sink" 180 | version = "0.3.15" 181 | source = "registry+https://github.com/rust-lang/crates.io-index" 182 | checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282" 183 | 184 | [[package]] 185 | name = "futures-task" 186 | version = "0.3.15" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" 189 | 190 | [[package]] 191 | name = "futures-util" 192 | version = "0.3.15" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" 195 | dependencies = [ 196 | "autocfg", 197 | "futures-channel", 198 | "futures-core", 199 | "futures-io", 200 | "futures-macro", 201 | "futures-sink", 202 | "futures-task", 203 | "memchr", 204 | "pin-project-lite", 205 | "pin-utils", 206 | "proc-macro-hack", 207 | "proc-macro-nested", 208 | "slab", 209 | ] 210 | 211 | [[package]] 212 | name = "hello" 213 | version = "0.1.0" 214 | dependencies = [ 215 | "aws_lambda_events", 216 | "http", 217 | "lambda_runtime", 218 | "log", 219 | "simple_logger", 220 | "tokio", 221 | ] 222 | 223 | [[package]] 224 | name = "hermit-abi" 225 | version = "0.1.19" 226 | source = "registry+https://github.com/rust-lang/crates.io-index" 227 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 228 | dependencies = [ 229 | "libc", 230 | ] 231 | 232 | [[package]] 233 | name = "http" 234 | version = "0.2.4" 235 | source = "registry+https://github.com/rust-lang/crates.io-index" 236 | checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" 237 | dependencies = [ 238 | "bytes 1.0.1", 239 | "fnv", 240 | "itoa", 241 | ] 242 | 243 | [[package]] 244 | name = "http-body" 245 | version = "0.4.2" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" 248 | dependencies = [ 249 | "bytes 1.0.1", 250 | "http", 251 | "pin-project-lite", 252 | ] 253 | 254 | [[package]] 255 | name = "http-serde" 256 | version = "1.0.3" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | checksum = "25698ac7002625796d5a7df8f0602400571da944c2edc1d5c268a6947dd4f692" 259 | dependencies = [ 260 | "http", 261 | "serde", 262 | ] 263 | 264 | [[package]] 265 | name = "httparse" 266 | version = "1.4.1" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" 269 | 270 | [[package]] 271 | name = "httpdate" 272 | version = "1.0.1" 273 | source = "registry+https://github.com/rust-lang/crates.io-index" 274 | checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" 275 | 276 | [[package]] 277 | name = "hyper" 278 | version = "0.14.10" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "7728a72c4c7d72665fde02204bcbd93b247721025b222ef78606f14513e0fd03" 281 | dependencies = [ 282 | "bytes 1.0.1", 283 | "futures-channel", 284 | "futures-core", 285 | "futures-util", 286 | "http", 287 | "http-body", 288 | "httparse", 289 | "httpdate", 290 | "itoa", 291 | "pin-project-lite", 292 | "socket2", 293 | "tokio", 294 | "tower-service", 295 | "tracing", 296 | "want", 297 | ] 298 | 299 | [[package]] 300 | name = "itoa" 301 | version = "0.4.7" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" 304 | 305 | [[package]] 306 | name = "lambda_runtime" 307 | version = "0.3.0" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "f9b08856997d11ca8122121b26b17a27ef1dce689d71ccd754e051f2417aebdd" 310 | dependencies = [ 311 | "async-stream", 312 | "bytes 1.0.1", 313 | "futures", 314 | "http", 315 | "hyper", 316 | "serde", 317 | "serde_json", 318 | "tokio", 319 | "tokio-stream", 320 | "tower-service", 321 | "tracing", 322 | "tracing-error", 323 | ] 324 | 325 | [[package]] 326 | name = "lazy_static" 327 | version = "1.4.0" 328 | source = "registry+https://github.com/rust-lang/crates.io-index" 329 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 330 | 331 | [[package]] 332 | name = "libc" 333 | version = "0.2.98" 334 | source = "registry+https://github.com/rust-lang/crates.io-index" 335 | checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" 336 | 337 | [[package]] 338 | name = "log" 339 | version = "0.4.14" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 342 | dependencies = [ 343 | "cfg-if", 344 | ] 345 | 346 | [[package]] 347 | name = "memchr" 348 | version = "2.4.0" 349 | source = "registry+https://github.com/rust-lang/crates.io-index" 350 | checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" 351 | 352 | [[package]] 353 | name = "mio" 354 | version = "0.7.13" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" 357 | dependencies = [ 358 | "libc", 359 | "log", 360 | "miow", 361 | "ntapi", 362 | "winapi", 363 | ] 364 | 365 | [[package]] 366 | name = "miow" 367 | version = "0.3.7" 368 | source = "registry+https://github.com/rust-lang/crates.io-index" 369 | checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" 370 | dependencies = [ 371 | "winapi", 372 | ] 373 | 374 | [[package]] 375 | name = "ntapi" 376 | version = "0.3.6" 377 | source = "registry+https://github.com/rust-lang/crates.io-index" 378 | checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" 379 | dependencies = [ 380 | "winapi", 381 | ] 382 | 383 | [[package]] 384 | name = "num-integer" 385 | version = "0.1.44" 386 | source = "registry+https://github.com/rust-lang/crates.io-index" 387 | checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" 388 | dependencies = [ 389 | "autocfg", 390 | "num-traits", 391 | ] 392 | 393 | [[package]] 394 | name = "num-traits" 395 | version = "0.2.14" 396 | source = "registry+https://github.com/rust-lang/crates.io-index" 397 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 398 | dependencies = [ 399 | "autocfg", 400 | ] 401 | 402 | [[package]] 403 | name = "num_cpus" 404 | version = "1.13.0" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" 407 | dependencies = [ 408 | "hermit-abi", 409 | "libc", 410 | ] 411 | 412 | [[package]] 413 | name = "once_cell" 414 | version = "1.8.0" 415 | source = "registry+https://github.com/rust-lang/crates.io-index" 416 | checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" 417 | 418 | [[package]] 419 | name = "pin-project-lite" 420 | version = "0.2.7" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" 423 | 424 | [[package]] 425 | name = "pin-utils" 426 | version = "0.1.0" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 429 | 430 | [[package]] 431 | name = "proc-macro-hack" 432 | version = "0.5.19" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" 435 | 436 | [[package]] 437 | name = "proc-macro-nested" 438 | version = "0.1.7" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" 441 | 442 | [[package]] 443 | name = "proc-macro2" 444 | version = "1.0.27" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" 447 | dependencies = [ 448 | "unicode-xid", 449 | ] 450 | 451 | [[package]] 452 | name = "quote" 453 | version = "1.0.9" 454 | source = "registry+https://github.com/rust-lang/crates.io-index" 455 | checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" 456 | dependencies = [ 457 | "proc-macro2", 458 | ] 459 | 460 | [[package]] 461 | name = "ryu" 462 | version = "1.0.5" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" 465 | 466 | [[package]] 467 | name = "serde" 468 | version = "1.0.126" 469 | source = "registry+https://github.com/rust-lang/crates.io-index" 470 | checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" 471 | dependencies = [ 472 | "serde_derive", 473 | ] 474 | 475 | [[package]] 476 | name = "serde_derive" 477 | version = "1.0.126" 478 | source = "registry+https://github.com/rust-lang/crates.io-index" 479 | checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" 480 | dependencies = [ 481 | "proc-macro2", 482 | "quote", 483 | "syn", 484 | ] 485 | 486 | [[package]] 487 | name = "serde_json" 488 | version = "1.0.64" 489 | source = "registry+https://github.com/rust-lang/crates.io-index" 490 | checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" 491 | dependencies = [ 492 | "itoa", 493 | "ryu", 494 | "serde", 495 | ] 496 | 497 | [[package]] 498 | name = "sharded-slab" 499 | version = "0.1.1" 500 | source = "registry+https://github.com/rust-lang/crates.io-index" 501 | checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" 502 | dependencies = [ 503 | "lazy_static", 504 | ] 505 | 506 | [[package]] 507 | name = "simple_logger" 508 | version = "1.11.0" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | checksum = "cd57f17c093ead1d4a1499dc9acaafdd71240908d64775465543b8d9a9f1d198" 511 | dependencies = [ 512 | "atty", 513 | "chrono", 514 | "colored", 515 | "log", 516 | "winapi", 517 | ] 518 | 519 | [[package]] 520 | name = "slab" 521 | version = "0.4.3" 522 | source = "registry+https://github.com/rust-lang/crates.io-index" 523 | checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" 524 | 525 | [[package]] 526 | name = "socket2" 527 | version = "0.4.0" 528 | source = "registry+https://github.com/rust-lang/crates.io-index" 529 | checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" 530 | dependencies = [ 531 | "libc", 532 | "winapi", 533 | ] 534 | 535 | [[package]] 536 | name = "syn" 537 | version = "1.0.73" 538 | source = "registry+https://github.com/rust-lang/crates.io-index" 539 | checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" 540 | dependencies = [ 541 | "proc-macro2", 542 | "quote", 543 | "unicode-xid", 544 | ] 545 | 546 | [[package]] 547 | name = "thread_local" 548 | version = "1.1.3" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" 551 | dependencies = [ 552 | "once_cell", 553 | ] 554 | 555 | [[package]] 556 | name = "time" 557 | version = "0.1.44" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" 560 | dependencies = [ 561 | "libc", 562 | "wasi", 563 | "winapi", 564 | ] 565 | 566 | [[package]] 567 | name = "tokio" 568 | version = "1.8.2" 569 | source = "registry+https://github.com/rust-lang/crates.io-index" 570 | checksum = "c2602b8af3767c285202012822834005f596c811042315fa7e9f5b12b2a43207" 571 | dependencies = [ 572 | "autocfg", 573 | "bytes 1.0.1", 574 | "libc", 575 | "memchr", 576 | "mio", 577 | "num_cpus", 578 | "pin-project-lite", 579 | "tokio-macros", 580 | "winapi", 581 | ] 582 | 583 | [[package]] 584 | name = "tokio-macros" 585 | version = "1.3.0" 586 | source = "registry+https://github.com/rust-lang/crates.io-index" 587 | checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110" 588 | dependencies = [ 589 | "proc-macro2", 590 | "quote", 591 | "syn", 592 | ] 593 | 594 | [[package]] 595 | name = "tokio-stream" 596 | version = "0.1.7" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f" 599 | dependencies = [ 600 | "futures-core", 601 | "pin-project-lite", 602 | "tokio", 603 | ] 604 | 605 | [[package]] 606 | name = "tower-service" 607 | version = "0.3.1" 608 | source = "registry+https://github.com/rust-lang/crates.io-index" 609 | checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" 610 | 611 | [[package]] 612 | name = "tracing" 613 | version = "0.1.26" 614 | source = "registry+https://github.com/rust-lang/crates.io-index" 615 | checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" 616 | dependencies = [ 617 | "cfg-if", 618 | "log", 619 | "pin-project-lite", 620 | "tracing-attributes", 621 | "tracing-core", 622 | ] 623 | 624 | [[package]] 625 | name = "tracing-attributes" 626 | version = "0.1.15" 627 | source = "registry+https://github.com/rust-lang/crates.io-index" 628 | checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" 629 | dependencies = [ 630 | "proc-macro2", 631 | "quote", 632 | "syn", 633 | ] 634 | 635 | [[package]] 636 | name = "tracing-core" 637 | version = "0.1.18" 638 | source = "registry+https://github.com/rust-lang/crates.io-index" 639 | checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" 640 | dependencies = [ 641 | "lazy_static", 642 | ] 643 | 644 | [[package]] 645 | name = "tracing-error" 646 | version = "0.1.2" 647 | source = "registry+https://github.com/rust-lang/crates.io-index" 648 | checksum = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24" 649 | dependencies = [ 650 | "tracing", 651 | "tracing-subscriber", 652 | ] 653 | 654 | [[package]] 655 | name = "tracing-subscriber" 656 | version = "0.2.19" 657 | source = "registry+https://github.com/rust-lang/crates.io-index" 658 | checksum = "ab69019741fca4d98be3c62d2b75254528b5432233fd8a4d2739fec20278de48" 659 | dependencies = [ 660 | "sharded-slab", 661 | "thread_local", 662 | "tracing-core", 663 | ] 664 | 665 | [[package]] 666 | name = "try-lock" 667 | version = "0.2.3" 668 | source = "registry+https://github.com/rust-lang/crates.io-index" 669 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" 670 | 671 | [[package]] 672 | name = "unicode-xid" 673 | version = "0.2.2" 674 | source = "registry+https://github.com/rust-lang/crates.io-index" 675 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 676 | 677 | [[package]] 678 | name = "want" 679 | version = "0.3.0" 680 | source = "registry+https://github.com/rust-lang/crates.io-index" 681 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 682 | dependencies = [ 683 | "log", 684 | "try-lock", 685 | ] 686 | 687 | [[package]] 688 | name = "wasi" 689 | version = "0.10.0+wasi-snapshot-preview1" 690 | source = "registry+https://github.com/rust-lang/crates.io-index" 691 | checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" 692 | 693 | [[package]] 694 | name = "winapi" 695 | version = "0.3.9" 696 | source = "registry+https://github.com/rust-lang/crates.io-index" 697 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 698 | dependencies = [ 699 | "winapi-i686-pc-windows-gnu", 700 | "winapi-x86_64-pc-windows-gnu", 701 | ] 702 | 703 | [[package]] 704 | name = "winapi-i686-pc-windows-gnu" 705 | version = "0.4.0" 706 | source = "registry+https://github.com/rust-lang/crates.io-index" 707 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 708 | 709 | [[package]] 710 | name = "winapi-x86_64-pc-windows-gnu" 711 | version = "0.4.0" 712 | source = "registry+https://github.com/rust-lang/crates.io-index" 713 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 714 | -------------------------------------------------------------------------------- /netlify/functions/hello/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2018" 3 | name = "hello" 4 | version = "0.1.0" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | aws_lambda_events = "0.4.0" 10 | http = "0.2.4" 11 | lambda_runtime = "0.3.0" 12 | log = "0.4.14" 13 | simple_logger = "1.11.0" 14 | tokio = "1.6.1" 15 | -------------------------------------------------------------------------------- /netlify/functions/hello/src/main.rs: -------------------------------------------------------------------------------- 1 | use aws_lambda_events::event::apigw::{ApiGatewayProxyRequest, ApiGatewayProxyResponse}; 2 | use aws_lambda_events::encodings::Body; 3 | use http::header::HeaderMap; 4 | use lambda_runtime::{handler_fn, Context, Error}; 5 | use log::LevelFilter; 6 | use simple_logger::SimpleLogger; 7 | 8 | #[tokio::main] 9 | async fn main() -> Result<(), Error> { 10 | SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap(); 11 | 12 | let func = handler_fn(my_handler); 13 | lambda_runtime::run(func).await?; 14 | Ok(()) 15 | } 16 | 17 | pub(crate) async fn my_handler(event: ApiGatewayProxyRequest, _ctx: Context) -> Result { 18 | let path = event.path.unwrap(); 19 | 20 | let resp = ApiGatewayProxyResponse { 21 | status_code: 200, 22 | headers: HeaderMap::new(), 23 | multi_value_headers: HeaderMap::new(), 24 | body: Some(Body::Text(format!("Hello from '{}'", path))), 25 | is_base64_encoded: Some(false), 26 | }; 27 | 28 | Ok(resp) 29 | } -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | Netlify Functions with support for Rust. 2 | 3 | Click here to invoke Rust code --------------------------------------------------------------------------------