Mux Router
Routes public requests through an owner-scoped path. No authentication is required.
The mux route is /mux/{owner_id}/*. The remaining path is forwarded to the owner's lambda routing logic.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
owner_id |
string | Owner identifier |
* |
path | Remaining path forwarded to the owner scope |
HTTP Request
curl -X GET "https://api.hola.cloud/mux/user_123/hello-world"GET /mux/user_123/hello-world HTTP/1.1
Host: api.hola.cloud
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, err := http.NewRequest("GET", "https://api.hola.cloud/mux/user_123/hello-world", nil)
if err != nil {
panic(err)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(responseBody))
}
<?php
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.hola.cloud/mux/user_123/hello-world',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
]);
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch));
}
curl_close($ch);
echo $response;
import requests
response = requests.request(
"GET",
"https://api.hola.cloud/mux/user_123/hello-world"
)
print(response.text)
const response = await fetch("https://api.hola.cloud/mux/user_123/hello-world", {
method: "GET"
});
console.log(await response.text());
const response = await fetch("https://api.hola.cloud/mux/user_123/hello-world", {
method: "GET"
});
const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.hola.cloud/mux/user_123/hello-world"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}Example
curl -X GET "https://api.hola.cloud/mux/user_123/hello-world"GET /mux/user_123/hello-world HTTP/1.1
Host: api.hola.cloud
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, err := http.NewRequest("GET", "https://api.hola.cloud/mux/user_123/hello-world", nil)
if err != nil {
panic(err)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(responseBody))
}
<?php
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.hola.cloud/mux/user_123/hello-world',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
]);
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch));
}
curl_close($ch);
echo $response;
import requests
response = requests.request(
"GET",
"https://api.hola.cloud/mux/user_123/hello-world"
)
print(response.text)
const response = await fetch("https://api.hola.cloud/mux/user_123/hello-world", {
method: "GET"
});
console.log(await response.text());
const response = await fetch("https://api.hola.cloud/mux/user_123/hello-world", {
method: "GET"
});
const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.hola.cloud/mux/user_123/hello-world"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}Response
The response is produced by the lambda selected by the owner route.
1{
2 "body": {
3 "message": "Hello from mux",
4 "path": "/hello-world"
5 }
6}
Error Codes
| Code | Description |
|---|---|
| 404 | Owner or lambda route not found |
| 500 | Lambda execution error |
Comments