diff --git a/templates/http-c/content/spin.toml b/templates/http-c/content/spin.toml index 437052025e..4646f49110 100644 --- a/templates/http-c/content/spin.toml +++ b/templates/http-c/content/spin.toml @@ -1,17 +1,19 @@ -spin_manifest_version = "1" -authors = ["{{authors}}"] -description = "{{project-description}}" +spin_manifest_version = 2 + +[application] name = "{{project-name}}" -trigger = { type = "http", base = "{{http-base}}" } version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" -[[component]] -id = "{{project-name | kebab_case}}" -source = "main.wasm" -allowed_http_hosts = [] -[component.trigger] +[[trigger.http]] route = "{{http-path}}" +component = "{{project-name | kebab_case}}" executor = { type = "wagi" } -[component.build] + +[component.{{project-name | kebab_case}}] +source = "main.wasm" +allowed_http_hosts = [] +[component.{{project-name | kebab_case}}.build] command = "zig build-exe -O ReleaseSmall -target wasm32-wasi main.c -lc" watch = ["**/*.c"] diff --git a/templates/http-c/metadata/spin-template.toml b/templates/http-c/metadata/spin-template.toml index 04e89dacd2..d3f4d105f2 100644 --- a/templates/http-c/metadata/spin-template.toml +++ b/templates/http-c/metadata/spin-template.toml @@ -5,5 +5,4 @@ tags = ["http", "c"] [parameters] project-description = { type = "string", prompt = "Description", default = "" } -http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" } http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" } diff --git a/templates/http-grain/content/spin.toml b/templates/http-grain/content/spin.toml index 5a3c566257..400d16ce53 100644 --- a/templates/http-grain/content/spin.toml +++ b/templates/http-grain/content/spin.toml @@ -1,17 +1,19 @@ -spin_manifest_version = "1" -authors = ["{{authors}}"] -description = "{{project-description}}" +spin_manifest_version = 2 + +[application] name = "{{project-name}}" -trigger = { type = "http", base = "{{http-base}}" } version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" -[[component]] -id = "{{project-name | kebab_case}}" -source = "main.wasm" -allowed_http_hosts = [] -[component.trigger] +[[trigger.http]] route = "{{http-path}}" +component = "{{project-name | kebab_case}}" executor = { type = "wagi" } -[component.build] + +[component.{{project-name | kebab_case}}] +source = "main.wasm" +allowed_http_hosts = [] +[component.{{project-name | kebab_case}}.build] command = "grain compile --release -o main.wasm main.gr" watch = ["**/*.gr"] diff --git a/templates/http-grain/metadata/spin-template.toml b/templates/http-grain/metadata/spin-template.toml index 9280d4e6b4..36e6e0bf82 100644 --- a/templates/http-grain/metadata/spin-template.toml +++ b/templates/http-grain/metadata/spin-template.toml @@ -5,5 +5,4 @@ tags = ["http", "grain"] [parameters] project-description = { type = "string", prompt = "Description", default = "" } -http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" } http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" } diff --git a/templates/http-php/content/spin.toml b/templates/http-php/content/spin.toml index 6e101e1a20..273250fa09 100644 --- a/templates/http-php/content/spin.toml +++ b/templates/http-php/content/spin.toml @@ -1,17 +1,19 @@ -spin_manifest_version = "1" -authors = ["{{authors}}"] -description = "{{project-description}}" +spin_manifest_version = 2 + +[application] name = "{{project-name}}" -trigger = { type = "http", base = "{{http-base}}" } version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" -[[component]] -id = "{{project-name | kebab_case}}" +[[trigger.http]] +route = "{{http-path}}" +component = "{{project-name | kebab_case}}" +executor = { type = "wagi"} + +[component.{{project-name | kebab_case}}] files = [ { source = "./src", destination = "/" } ] allowed_http_hosts = [] -[component.source] +[component.{{project-name | kebab_case}}.source] url = "https://github.com/vmware-labs/webassembly-language-runtimes/releases/download/php%2F7.4.32%2B20221124-2159d1c/php-cgi-7.4.32.speed-optimized.wasm" digest = "sha256:511720698dee56134ed8a08a87131d33c3ea8a64b6726cd6710d624bca4ceb6c" -[component.trigger] -executor = { type = "wagi"} -route = "{{http-path}}" diff --git a/templates/http-php/metadata/spin-template.toml b/templates/http-php/metadata/spin-template.toml index 2dd05dee25..acc56d06e8 100644 --- a/templates/http-php/metadata/spin-template.toml +++ b/templates/http-php/metadata/spin-template.toml @@ -5,5 +5,4 @@ tags = ["http", "php"] [parameters] project-description = { type = "string", prompt = "Description", default = "" } -http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" } http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" } diff --git a/templates/http-swift/content/spin.toml b/templates/http-swift/content/spin.toml index 95f4e87b85..6d941a205f 100644 --- a/templates/http-swift/content/spin.toml +++ b/templates/http-swift/content/spin.toml @@ -1,17 +1,19 @@ -spin_manifest_version = "1" -authors = ["{{authors}}"] -description = "{{project-description}}" +spin_manifest_version = 2 + +[application] name = "{{project-name}}" -trigger = { type = "http", base = "{{http-base}}" } version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" -[[component]] -id = "{{project-name | kebab_case}}" -source = "main.wasm" -allowed_http_hosts = [] -[component.trigger] +[[trigger.http]] route = "{{http-path}}" +component = "{{project-name | kebab_case}}" executor = { type = "wagi" } -[component.build] + +[component.{{project-name | kebab_case}}] +source = "main.wasm" +allowed_http_hosts = [] +[component.{{project-name | kebab_case}}.build] command = "swiftc -target wasm32-unknown-wasi main.swift -o main.wasm" watch = ["**/*.swift"] diff --git a/templates/http-swift/metadata/spin-template.toml b/templates/http-swift/metadata/spin-template.toml index 9f125e9f13..ce0e3df49a 100644 --- a/templates/http-swift/metadata/spin-template.toml +++ b/templates/http-swift/metadata/spin-template.toml @@ -5,5 +5,4 @@ tags = ["http", "swift"] [parameters] project-description = { type = "string", prompt = "Description", default = "" } -http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" } http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" } diff --git a/templates/http-zig/content/spin.toml b/templates/http-zig/content/spin.toml index 87bb75a272..345e767044 100644 --- a/templates/http-zig/content/spin.toml +++ b/templates/http-zig/content/spin.toml @@ -1,17 +1,19 @@ -spin_manifest_version = "1" -authors = ["{{authors}}"] -description = "{{project-description}}" +spin_manifest_version = 2 + +[application] name = "{{project-name}}" -trigger = { type = "http", base = "{{http-base}}" } version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" -[[component]] -id = "{{project-name | kebab_case}}" -source = "main.wasm" -allowed_http_hosts = [] -[component.trigger] +[[trigger.http]] route = "{{http-path}}" +component = "{{project-name | kebab_case}}" executor = { type = "wagi" } -[component.build] + +[component.{{project-name | kebab_case}}] +source = "main.wasm" +allowed_http_hosts = [] +[component.{{project-name | kebab_case}}.build] command = "zig build-exe -O ReleaseSmall -target wasm32-wasi src/main.zig" watch = ["src/**/*.zig"] diff --git a/templates/http-zig/metadata/spin-template.toml b/templates/http-zig/metadata/spin-template.toml index e607ba5e73..d1219fa8eb 100644 --- a/templates/http-zig/metadata/spin-template.toml +++ b/templates/http-zig/metadata/spin-template.toml @@ -5,5 +5,4 @@ tags = ["http", "zig"] [parameters] project-description = { type = "string", prompt = "Description", default = "" } -http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" } http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" } diff --git a/templates/redirect/content/spin.toml b/templates/redirect/content/spin.toml index 8e9195f0cc..f74ea71de2 100644 --- a/templates/redirect/content/spin.toml +++ b/templates/redirect/content/spin.toml @@ -1,13 +1,15 @@ -spin_manifest_version = "1" -authors = ["{{authors}}"] -description = "{{project-description}}" +spin_manifest_version = 2 + +[application] name = "{{project-name}}" -trigger = { type = "http", base = "{{http-base}}" } version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" + +[[trigger.http]] +route = "{{ redirect-from }}" +component = "{{project-name | kebab_case}}" -[[component]] +[component.{{project-name | kebab_case}}] source = { url = "https://github.com/fermyon/spin-redirect/releases/download/v0.1.0/redirect.wasm", digest = "sha256:8bee959843f28fef2a02164f5840477db81d350877e1c22cb524f41363468e52" } -id = "{{ project-name | kebab_case }}" environment = { DESTINATION = "{{ redirect-to }}" } -[component.trigger] -route = "{{ redirect-from }}" diff --git a/templates/redirect/metadata/snippets/component.txt b/templates/redirect/metadata/snippets/component.txt index 5ae6628514..e7117b466e 100644 --- a/templates/redirect/metadata/snippets/component.txt +++ b/templates/redirect/metadata/snippets/component.txt @@ -1,6 +1,7 @@ -[[component]] +[[trigger.http]] +route = "{{ redirect-from }}" +component = "{{project-name | kebab_case}}" + +[component.{{project-name | kebab_case}}] source = { url = "https://github.com/fermyon/spin-redirect/releases/download/v0.1.0/redirect.wasm", digest = "sha256:8bee959843f28fef2a02164f5840477db81d350877e1c22cb524f41363468e52" } -id = "{{ project-name | kebab_case }}" environment = { DESTINATION = "{{ redirect-to }}" } -[component.trigger] -route = "{{ redirect-from }}" diff --git a/templates/redirect/metadata/spin-template.toml b/templates/redirect/metadata/spin-template.toml index 7681441047..28580f10b0 100644 --- a/templates/redirect/metadata/spin-template.toml +++ b/templates/redirect/metadata/spin-template.toml @@ -6,12 +6,11 @@ tags = ["redirect"] [add_component] skip_files = ["spin.toml"] -skip_parameters = ["project-description", "http-base"] +skip_parameters = ["project-description"] [add_component.snippets] component = "component.txt" [parameters] project-description = { type = "string", prompt = "Description", default = "" } -http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" } redirect-from = { type = "string", prompt = "Redirect from", pattern = "^/\\S*$" } redirect-to = { type = "string", prompt = "Redirect to" } diff --git a/templates/static-fileserver/content/spin.toml b/templates/static-fileserver/content/spin.toml index ca7e89c444..e527a47aef 100644 --- a/templates/static-fileserver/content/spin.toml +++ b/templates/static-fileserver/content/spin.toml @@ -1,13 +1,15 @@ -spin_manifest_version = "1" -authors = ["{{authors}}"] -description = "{{project-description}}" +spin_manifest_version = 2 + +[application] name = "{{project-name}}" -trigger = { type = "http", base = "{{http-base}}" } version = "0.1.0" +authors = ["{{authors}}"] +description = "{{project-description}}" + +[[trigger.http]] +route = "{{ http-path | http_wildcard }}" +component = "{{project-name | kebab_case}}" -[[component]] +[component.{{project-name | kebab_case}}] source = { url = "https://github.com/fermyon/spin-fileserver/releases/download/v0.1.0/spin_static_fs.wasm", digest = "sha256:96c76d9af86420b39eb6cd7be5550e3cb5d4cc4de572ce0fd1f6a29471536cb4" } -id = "{{ project-name }}" files = [{ source = "{{ files-path }}", destination = "/" }] -[component.trigger] -route = "{{ http-path | http_wildcard }}" diff --git a/templates/static-fileserver/metadata/snippets/component.txt b/templates/static-fileserver/metadata/snippets/component.txt index 68d604349d..1caa0f6dc3 100644 --- a/templates/static-fileserver/metadata/snippets/component.txt +++ b/templates/static-fileserver/metadata/snippets/component.txt @@ -1,6 +1,7 @@ -[[component]] -source = { url = "https://github.com/fermyon/spin-fileserver/releases/download/v0.1.0/spin_static_fs.wasm", digest = "sha256:96c76d9af86420b39eb6cd7be5550e3cb5d4cc4de572ce0fd1f6a29471536cb4" } -id = "{{ project-name }}" -files = [ { source = "{{ files-path }}", destination = "/" } ] -[component.trigger] +[[trigger.http]] route = "{{ http-path | http_wildcard }}" +component = "{{project-name | kebab_case}}" + +[component.{{project-name | kebab_case}}] +source = { url = "https://github.com/fermyon/spin-fileserver/releases/download/v0.1.0/spin_static_fs.wasm", digest = "sha256:96c76d9af86420b39eb6cd7be5550e3cb5d4cc4de572ce0fd1f6a29471536cb4" } +files = [{ source = "{{ files-path }}", destination = "/" }] diff --git a/templates/static-fileserver/metadata/spin-template.toml b/templates/static-fileserver/metadata/spin-template.toml index 9399a04dad..00ae333541 100644 --- a/templates/static-fileserver/metadata/spin-template.toml +++ b/templates/static-fileserver/metadata/spin-template.toml @@ -6,12 +6,11 @@ tags = ["http", "file", "static", "asset"] [add_component] skip_files = ["spin.toml", ".gitignore"] -skip_parameters = ["http-base", "project-description"] +skip_parameters = ["project-description"] [add_component.snippets] component = "component.txt" [parameters] project-description = { type = "string", prompt = "Description", default = "" } -http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" } http-path = { type = "string", prompt = "HTTP path", default = "/static/...", pattern = "^/\\S*$" } files-path = { type = "string", prompt = "Directory containing the files to serve", default = "assets", pattern = "^\\S+$" }