You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: examples/http-certification/assets/README.md
+6-7
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ fn post_upgrade() {
76
76
77
77
## Canister endpoints
78
78
79
-
There is only one canister endpoint in this example to serve assets, `http_request` query endpoint. The `serve_metrics` and `serve_asset` functions will be covered in a later section.
79
+
There is only one canister endpoint in this example to serve assets, the `http_request` query endpoint. The `http_request` handler uses two auxiliary functions, `serve_metrics` and `serve_asset`, which are covered in a later section.
80
80
81
81
```rust
82
82
#[query]
@@ -164,14 +164,13 @@ The `certify_all_assets` function performs the following steps:
You can now access the canister's assets by navigating to the canister's URL in a web browser. The URL can also be found using the following command, making sure to replace `backend` with the name of the canister:
351
+
You can now access the canister's assets by navigating to the canister's URL in a web browser. The URL can also be found using the following command:
353
352
354
353
```shell
355
354
echo"http://$(dfx canister id http_certification_assets_backend).localhost:$(dfx info webserver-port)"
356
355
```
357
356
358
-
Alternatively, to make a request with cURL, again making sure to replace `backend` with the name of the canister:
357
+
Alternatively, to make a request with `curl`:
359
358
360
359
```shell
361
360
curl "http://$(dfx canister id http_certification_assets_backend).localhost:$(dfx info webserver-port)" --resolve "$(dfx canister id http_certification_assets_backend).localhost:$(dfx info webserver-port):127.0.0.1"
Copy file name to clipboardexpand all lines: examples/http-certification/custom-assets/README.md
+56-88
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,6 @@ The lifecycle hooks are set up similarly to the JSON API.
67
67
```rust
68
68
#[init]
69
69
fninit() {
70
-
prepare_cel_exprs();
71
70
certify_all_assets();
72
71
}
73
72
@@ -79,30 +78,17 @@ fn post_upgrade() {
79
78
80
79
## CEL Expressions
81
80
82
-
CEL expressions are also stored similarly to the [JSON API example](https://internetcomputer.org/docs/current/developer-docs/http-compatible-canisters/serving-json-over-http).
81
+
The CEL expression definition is simpler in the case of assets compared to the [JSON API example](https://internetcomputer.org/docs/current/developer-docs/http-compatible-canisters/serving-json-over-http) as the same CEL expression is used for every asset, including the fallback response.
It's also possible to skip certification for certain routes. This can be useful for scenarios where it's difficult to predict what the response will look like for a certain route and the content is not very security sensitive. This can be done as follows:
363
+
It's also possible to skip certification for certain routes. This can be useful for scenarios where it's difficult to predict what the response will look like for a certain route and the content is not very security sensitive. This can be done for example with metrics served on the `/metrics` route as follows:
You can now access the canister's assets by navigating to the canister's URL in a web browser. The URL can also be found using the following command, making sure to replace `backend` with the name of the canister:
565
+
You can now access the canister's assets by navigating to the canister's URL in a web browser. The URL can also be found using the following command:
598
566
599
567
```shell
600
568
echo"http://$(dfx canister id http_certification_custom_assets_backend).localhost:$(dfx info webserver-port)"
601
569
```
602
570
603
-
Alternatively, to make a request with cURL, again making sure to replace `backend` with the name of the canister:
571
+
Alternatively, to make a request with `curl`:
604
572
605
573
```shell
606
574
curl "http://$(dfx canister id http_certification_custom_assets_backend).localhost:$(dfx info webserver-port)" --resolve "$(dfx canister id http_certification_custom_assets_backend).localhost:$(dfx info webserver-port):127.0.0.1"
0 commit comments