-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (30 loc) · 892 Bytes
/
main.go
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
30
31
32
33
34
35
36
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/apple-app-site-association", appleHandler())
http.HandleFunc("/.well-known/", wellknownHandler())
port := 4000
log.Printf("Serving http at port %d...\n", port)
if err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil); err != nil {
log.Fatal(err)
}
}
func appleHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fileServer := http.FileServer(http.Dir("./static/well-known/"))
w.Header().Set("content-type", "application/json")
fileServer.ServeHTTP(w, r)
}
}
func wellknownHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fileServer := http.FileServer(http.Dir("./static/well-known/"))
w.Header().Set("content-type", "application/json")
s := http.StripPrefix("/.well-known/", fileServer)
s.ServeHTTP(w, r)
}
}