Live video on the AT Protocol
1package api
2
3import (
4 "context"
5 "encoding/json"
6 "log"
7 "net/http"
8)
9
10// https://docs.expo.dev/linking/ios-universal-links/
11func (a *StreamplaceAPI) HandleAppleAppSiteAssociation(ctx context.Context) http.HandlerFunc {
12 return func(w http.ResponseWriter, r *http.Request) {
13 if a.CLI.AppleTeamID == "" || a.CLI.AppBundleID == "" {
14 w.WriteHeader(http.StatusNotFound)
15 return
16 }
17 w.Header().Set("Content-Type", "application/json")
18 data := map[string]any{
19 "applinks": map[string]any{
20 "apps": []string{},
21 "details": []map[string]any{
22 {
23 "appID": a.CLI.AppleTeamID + "." + a.CLI.AppBundleID,
24 "paths": []string{"*", "NOT /docs/*", "NOT /api/*", "NOT /xrpc/*", "NOT /oauth/*", "NOT /.well-known/*"},
25 },
26 },
27 },
28 "activitycontinuation": map[string]any{
29 "apps": []string{a.CLI.AppleTeamID + "." + a.CLI.AppBundleID},
30 },
31 "webcredentials": map[string]any{
32 "apps": []string{a.CLI.AppleTeamID + "." + a.CLI.AppBundleID},
33 },
34 }
35 err := json.NewEncoder(w).Encode(data)
36 if err != nil {
37 log.Printf("error encoding apple app site association: %v", err)
38 w.WriteHeader(http.StatusInternalServerError)
39 return
40 }
41 }
42}
43
44// https://docs.expo.dev/linking/android-app-links/
45func (a *StreamplaceAPI) HandleAndroidAssetLinks(ctx context.Context) http.HandlerFunc {
46 return func(w http.ResponseWriter, r *http.Request) {
47 if a.CLI.AndroidCertFingerprint == "" || a.CLI.AppBundleID == "" {
48 w.WriteHeader(http.StatusNotFound)
49 return
50 }
51 w.Header().Set("Content-Type", "application/json")
52 data := []map[string]any{
53 {
54 "relation": []string{"delegate_permission/common.handle_all_urls"},
55 "target": map[string]any{
56 "namespace": "android_app",
57 "package_name": a.CLI.AppBundleID,
58 "sha256_cert_fingerprints": []string{
59 a.CLI.AndroidCertFingerprint,
60 },
61 },
62 },
63 }
64 err := json.NewEncoder(w).Encode(data)
65 if err != nil {
66 log.Printf("error encoding android asset links: %v", err)
67 w.WriteHeader(http.StatusInternalServerError)
68 return
69 }
70 }
71}