Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.0.0"

[dependencies]
log = "0.4"
regex = "1.9"
url = "2.4"

# Mandatory for cargo-raze
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ unit test that verifies both.

Build all plugins and run all plugin tests:

`$ bazelisk test --test_output=all --define engine=v8 samples/...`
`$ bazelisk test --test_output=all //samples/...`

# Samples & Recipes

Expand All @@ -29,6 +29,9 @@ plugin. Extend them to fit your particular use case.
* [Log the value of a query parameter](samples/query_log): Emit a custom
variable to Cloud Logging. Demonstrate a standard way to parse query string
values from the request.
* [Rewrite the path using regex](samples/regex_rewrite): Remove a piece of the
URI using regex replacement. Demonstrate a standard way to use regular
expressions, compiling them at plugin initialization.

# Feature set / ABI

Expand Down
19 changes: 13 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,20 @@ http_archive(
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
boost_deps()

# Upgrade googletest to v1.13.0 to support bazel 6.0.0
# TODO merge upstream to proxy-wasm-cpp-host/bazel/repositories.bzl
# Include Google RE2.
http_archive(
name = "com_google_googletest",
sha256 = "ad7fdba11ea011c1d925b3289cf4af2c66a352e18d4c7264392fead75e919363",
strip_prefix = "googletest-1.13.0",
url = "https://github.com/google/googletest/archive/v1.13.0.tar.gz",
name = "com_google_re2",
sha256 = "18cf85922e27fad3ed9c96a27733037da445f35eb1a2744c306a37c6d11e95c4",
strip_prefix = "re2-2023-07-01",
url = "https://github.com/google/re2/archive/2023-07-01.tar.gz",
)

# Upgrade Abseil to work with latest Emscripten and STANDALONE_WASM
http_archive(
name = "com_google_absl", # 2023-04-06T14:42:25Z
sha256 = "a50452f02402262f9a61a8eedda60f76dda6b9538d36b34b55bce9f74a4d5ef8",
strip_prefix = "abseil-cpp-e73b9139ee9b853a4bd7812531442c138da09084",
urls = ["https://github.com/abseil/abseil-cpp/archive/e73b9139ee9b853a4bd7812531442c138da09084.zip"],
)

# Duplicate ProxyWasm WORKSPACE files (dependencies)
Expand Down
9 changes: 9 additions & 0 deletions cargo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ alias(
],
)

alias(
name = "regex",
actual = "@raze__regex__1_9_1//:regex",
tags = [
"cargo-raze",
"manual",
],
)

alias(
name = "url",
actual = "@raze__url__2_4_0//:url",
Expand Down
45 changes: 45 additions & 0 deletions cargo/Cargo.raze.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "aho-corasick"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
dependencies = [
"memchr",
]

[[package]]
name = "form_urlencoded"
version = "1.2.0"
Expand All @@ -25,17 +34,53 @@ version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"

[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"

[[package]]
name = "percent-encoding"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"

[[package]]
name = "regex"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]

[[package]]
name = "regex-automata"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]

[[package]]
name = "regex-syntax"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"

[[package]]
name = "service-extensions-samples"
version = "0.0.0"
dependencies = [
"log",
"regex",
"url",
]

Expand Down
50 changes: 50 additions & 0 deletions cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: di

def raze_fetch_remote_crates():
"""This function defines a collection of repos and should be called in a WORKSPACE file"""
maybe(
http_archive,
name = "raze__aho_corasick__1_0_2",
url = "https://crates.io/api/v1/crates/aho-corasick/1.0.2/download",
type = "tar.gz",
sha256 = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41",
strip_prefix = "aho-corasick-1.0.2",
build_file = Label("//cargo/remote:BUILD.aho-corasick-1.0.2.bazel"),
)

maybe(
http_archive,
name = "raze__form_urlencoded__1_2_0",
Expand Down Expand Up @@ -41,6 +51,16 @@ def raze_fetch_remote_crates():
build_file = Label("//cargo/remote:BUILD.log-0.4.19.bazel"),
)

maybe(
http_archive,
name = "raze__memchr__2_5_0",
url = "https://crates.io/api/v1/crates/memchr/2.5.0/download",
type = "tar.gz",
sha256 = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d",
strip_prefix = "memchr-2.5.0",
build_file = Label("//cargo/remote:BUILD.memchr-2.5.0.bazel"),
)

maybe(
http_archive,
name = "raze__percent_encoding__2_3_0",
Expand All @@ -51,6 +71,36 @@ def raze_fetch_remote_crates():
build_file = Label("//cargo/remote:BUILD.percent-encoding-2.3.0.bazel"),
)

maybe(
http_archive,
name = "raze__regex__1_9_1",
url = "https://crates.io/api/v1/crates/regex/1.9.1/download",
type = "tar.gz",
sha256 = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575",
strip_prefix = "regex-1.9.1",
build_file = Label("//cargo/remote:BUILD.regex-1.9.1.bazel"),
)

maybe(
http_archive,
name = "raze__regex_automata__0_3_3",
url = "https://crates.io/api/v1/crates/regex-automata/0.3.3/download",
type = "tar.gz",
sha256 = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310",
strip_prefix = "regex-automata-0.3.3",
build_file = Label("//cargo/remote:BUILD.regex-automata-0.3.3.bazel"),
)

maybe(
http_archive,
name = "raze__regex_syntax__0_7_4",
url = "https://crates.io/api/v1/crates/regex-syntax/0.7.4/download",
type = "tar.gz",
sha256 = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2",
strip_prefix = "regex-syntax-0.7.4",
build_file = Label("//cargo/remote:BUILD.regex-syntax-0.7.4.bazel"),
)

maybe(
http_archive,
name = "raze__tinyvec__1_6_0",
Expand Down
58 changes: 58 additions & 0 deletions cargo/remote/BUILD.aho-corasick-1.0.2.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
@generated
cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

# buildifier: disable=load
load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"unencumbered", # Unlicense from expression "Unlicense OR MIT"
])

# Generated Targets

rust_library(
name = "aho_corasick",
srcs = glob(["**/*.rs"]),
crate_features = [
"default",
"perf-literal",
"std",
],
crate_root = "src/lib.rs",
data = [],
edition = "2021",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-raze",
"crate-name=aho_corasick",
"manual",
],
version = "1.0.2",
# buildifier: leave-alone
deps = [
"@raze__memchr__2_5_0//:memchr",
],
)
88 changes: 88 additions & 0 deletions cargo/remote/BUILD.memchr-2.5.0.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""
@generated
cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

# buildifier: disable=load
load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_library",
"rust_proc_macro",
"rust_test",
)

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"unencumbered", # Unlicense from expression "Unlicense OR MIT"
])

# Generated Targets
# buildifier: disable=out-of-order-load
# buildifier: disable=load-on-top
load(
"@rules_rust//cargo:cargo_build_script.bzl",
"cargo_build_script",
)

cargo_build_script(
name = "memchr_build_script",
srcs = glob(["**/*.rs"]),
build_script_env = {
},
crate_features = [
"default",
"std",
],
crate_root = "build.rs",
data = glob(["**"]),
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-raze",
"manual",
],
version = "2.5.0",
visibility = ["//visibility:private"],
deps = [
],
)

rust_library(
name = "memchr",
srcs = glob(["**/*.rs"]),
crate_features = [
"default",
"std",
],
crate_root = "src/lib.rs",
data = [],
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-raze",
"crate-name=memchr",
"manual",
],
version = "2.5.0",
# buildifier: leave-alone
deps = [
":memchr_build_script",
],
)
Loading