-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
256 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
--- | ||
|
||
v0.0.1 - "Hello, world! version" - 2021 by `Jeremy Carter <[email protected]>` | ||
v0.1.0 - 2021 by `Jeremy Carter <[email protected]>` | ||
|
||
GitLab: [https://gitlab.com/defcronyke/rust-playground-api](https://gitlab.com/defcronyke/rust-playground-api) | ||
GitHub: [https://github.com/defcronyke/rust-playground-api](https://github.com/defcronyke/rust-playground-api) | ||
|
@@ -60,17 +60,38 @@ cd rust-playground-api | |
|
||
--- | ||
|
||
## Usage | ||
|
||
1. Make a GitHub `secret` or `public` Gist, with your desired `Rust` program code in it: | ||
[https://gist.github.com](https://gist.github.com) | ||
|
||
2. Get the Gist's ID from its URL, for example the `id` value as below: | ||
https://gist.github.com/{username}/{id} | ||
|
||
3. Run the `Rust` code by using the `id` in your GET request, for example: | ||
[http://localhost:8080/?id=1ea016619193533f9ac6cd1d8ae22d58](http://localhost:8080/?id=1ea016619193533f9ac6cd1d8ae22d58) | ||
|
||
--- | ||
|
||
## API routes available | ||
|
||
- Run the code: GET / [http://localhost:8080](http://localhost:8080) | ||
_Use your desired "GitHub Gist ID" for the `id` GET query parameter in the example requests below. The `Rust` code in that Gist will be used for | ||
the query._ | ||
|
||
- Run the code: | ||
GET /?id=1ea016619193533f9ac6cd1d8ae22d58 [http://localhost:8080/?id=1ea016619193533f9ac6cd1d8ae22d58](http://localhost:8080/?id=1ea016619193533f9ac6cd1d8ae22d58) | ||
|
||
- Run the test suite: GET /test [http://localhost:8080/test](http://localhost:8080/test) | ||
- Run the test suite: | ||
GET /test?id=1ea016619193533f9ac6cd1d8ae22d58 [http://localhost:8080/test?id=1ea016619193533f9ac6cd1d8ae22d58](http://localhost:8080/test?id=1ea016619193533f9ac6cd1d8ae22d58) | ||
|
||
- Build the code: GET /build [http://localhost:8080/build](http://localhost:8080/build) | ||
- Build the code: | ||
GET /build?id=1ea016619193533f9ac6cd1d8ae22d58 [http://localhost:8080/build?id=1ea016619193533f9ac6cd1d8ae22d58](http://localhost:8080/build?id=1ea016619193533f9ac6cd1d8ae22d58) | ||
|
||
- Build and output WebAssembly of the code: GET /wasm [http://localhost:8080/wasm](http://localhost:8080/wasm) | ||
- Build and output WebAssembly of the code: | ||
GET /wasm?id=1ea016619193533f9ac6cd1d8ae22d58 [http://localhost:8080/wasm?id=1ea016619193533f9ac6cd1d8ae22d58](http://localhost:8080/wasm?id=1ea016619193533f9ac6cd1d8ae22d58) | ||
|
||
- Build and output Assembly of the code: GET /asm [http://localhost:8080/asm](http://localhost:8080/asm) | ||
- Build and output Assembly of the code: | ||
GET /asm?id=1ea016619193533f9ac6cd1d8ae22d58 [http://localhost:8080/asm?id=1ea016619193533f9ac6cd1d8ae22d58](http://localhost:8080/asm?id=1ea016619193533f9ac6cd1d8ae22d58) | ||
|
||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# Depends on the 'jq' tool. | ||
|
||
rust_playground_api_asm_gist() { | ||
input_str="$@" | ||
|
||
if [ $# -eq 0 ]; then | ||
input_str="1ea016619193533f9ac6cd1d8ae22d58" | ||
fi | ||
|
||
input_str2="$(printf '%s' "$(./gist.sh "$input_str")")" | ||
input_str2="${input_str2%\"}" | ||
input_str2="${input_str2#\"}" | ||
|
||
input_param="$(printf '%b' "$input_str2"|jq -sRr @uri)" | ||
|
||
curl -sL -H 'Content-Type: application/json' -X POST -d '{"channel":"nightly","mode":"debug","edition":"2018","crateType":"bin","tests":false,"code":"'"$input_str2"'","target":"asm","assemblyFlavor":"att","demangleAssembly":"demangle","processAssembly":"filter","backtrace":false}' -H "Referrer: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&code=$input_param" https://play.rust-lang.org/compile | ||
} | ||
|
||
rust_playground_api_asm_gist "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# Depends on the 'jq' tool. | ||
|
||
rust_playground_api_build_gist() { | ||
input_str="$@" | ||
|
||
if [ $# -eq 0 ]; then | ||
input_str="1ea016619193533f9ac6cd1d8ae22d58" | ||
fi | ||
|
||
input_str2="$(printf '%s' "$(./gist.sh "$input_str")")" | ||
input_str2="${input_str2%\"}" | ||
input_str2="${input_str2#\"}" | ||
|
||
input_param="$(printf '%b' "$input_str2"|jq -sRr @uri)" | ||
|
||
curl -sL -H 'Content-Type: application/json' -X POST -d '{"channel":"nightly","mode":"debug","edition":"2018","crateType":"lib","tests":false,"code":"'"$input_str2"'","backtrace":false}' -H "Referrer: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&code=$input_param" https://play.rust-lang.org/execute | ||
} | ||
|
||
rust_playground_api_build_gist "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# Depends on the 'jq' tool. | ||
# | ||
# Example: ./gist.sh 1ea016619193533f9ac6cd1d8ae22d58 | ||
|
||
rust_playground_api_gist() { | ||
input_str="$@" | ||
|
||
curl -sL -H 'Accept: application/vnd.github.v3+json.raw' "https://api.github.com/gists/$input_str" | \ | ||
jq '.files | to_entries | .[0].value.content' | ||
} | ||
|
||
rust_playground_api_gist "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# Depends on the 'jq' tool. | ||
|
||
rust_playground_api_run_gist() { | ||
input_str="$@" | ||
|
||
if [ $# -eq 0 ]; then | ||
input_str="1ea016619193533f9ac6cd1d8ae22d58" | ||
fi | ||
|
||
input_str2="$(printf '%s' "$(./gist.sh "$input_str")")" | ||
input_str2="${input_str2%\"}" | ||
input_str2="${input_str2#\"}" | ||
|
||
input_param="$(printf '%b' "$input_str2"|jq -sRr @uri)" | ||
|
||
curl -sL -H 'Content-Type: application/json' -X POST -d '{"channel":"nightly","mode":"debug","edition":"2018","crateType":"bin","tests":false,"code":"'"$input_str2"'","backtrace":false}' -H "Referrer: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&code=$input_param" https://play.rust-lang.org/execute | ||
} | ||
|
||
rust_playground_api_run_gist "$@" |
Oops, something went wrong.