This is an example application that demonstrates the features of the EDJX platform.
This app implements a simple URL shortener.
The app consists of these components:
- URL shortening function
- Source code: rust_url_shorten (Rust)
- Takes a URL and generates a short string
- The URL is passed to the function in a
url
query parameter
- URL fetch function
- Source code: rust_url_fetch (Rust) or cpp_url_fetch (C++)
- Given a short string, it redirects to the full URL
- The short string is passed to the function in an
s
query parameter
- HTML page
- Source code: html (HTML, CSS, JavaScript)
- Provides a user interface for the functions
- Build and deploy the application code:
- Create a new
edjurl
application in the EDJX Console. - Build the rust_url_shorten code to get a
urlshorten.wasm
file. - Create a new
shorten
function inside theedjurl
application in the EDJX Console, select theurlshorten.wasm
file. - Build the rust_url_fetch (or cpp_url_fetch) code to get a
urlfetch.wasm
file. - Create a new
fetch
function inside theedjurl
application in the EDJX Console, select theurlfetch.wasm
file.
- Create a new
- Deploy the HTML page:
- In the html/scripts.js file, change
- the
APP_URL
variable to the URL of the deployedshorten
function (it will be used by JavaScript), - the
FETCH_PREFIX
variable to the URL of the deployedfetch
function followed by the?s=
query string (it will be displayed to the user).
- the
- Create a new
edjurl
bucket in the EDJX Console. - Upload all files from the html folder to the new
edjurl
bucket. - In the EDJX Console, set the
Content-Disposition
header to the valueinline
for theindex.html
file so that accessing the file URL in a web browser displays the HTML page instead of downloading it as a file.
- In the html/scripts.js file, change
- Add a domain (optional):
- If you own a domain (e.g.,
example.org
), you can add the domain to the EDJX Console. - Add an SSL/TLS certificate in the domain settings in the EDJX Console in order to enable HTTPS traffic.
- You can set Request Routing rules in the EDJX Console so that (in this order):
example.org/?s=*
(pattern match) redirects tohttps://[AppID].fn.edjx.net/fetch?{query}
example.org
(exact match) redirects to the HTML page in the buckethttps://[BucketID].storage.edjx.net/blobs/index.html
- If the domain is set up correctly, visiting
https://example.org
in a web browser will display the EdjURL home page. A shortened URL will look like this:https://example.org/?s=SHORTSTRING
.
- If you own a domain (e.g.,