Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"fmt"
"net/http"
)
func gateway(w http.ResponseWriter, r *http.Request) {
apiKey := r.Header.Get("X-API-Key")
if apiKey != "secret-key" {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
return
}
// Simulated rate limit check
fmt.Println("Rate limit passed")
// Simulated aggregation
user := "User Profile"
orders := "Recent Orders"
fmt.Fprintf(w, "%s | %s", user, orders)
}
func main() {
http.HandleFunc("/dashboard", gateway)
fmt.Println("API Gateway listening on :8080")
http.ListenAndServe(":8080", nil)
}Coding works best on desktop or with an external keyboard.