Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
support manifest/pwa stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Apr 2, 2019
1 parent bbf6621 commit efebf3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func authMiddleware(next http.Handler) http.Handler {
return
}

if path == "manifest-"+manifestKey+"/manifest.json" {
r.URL.Path = "/manifest/manifest.json"
}

next.ServeHTTP(w, r)
return
})
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var log = zerolog.New(os.Stderr).Output(zerolog.ConsoleWriter{Out: os.Stderr})
var scookie = securecookie.New([]byte("ilsvfoisg7rils3g4fo8segzr"), []byte("OHAOHDP4BLAKBDPAS3BÇSF"))
var httpPublic = &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: ""}
var accessKey string
var manifestKey string
var login string

func main() {
Expand Down Expand Up @@ -80,6 +81,7 @@ func main() {
login = cuid.New() + ":" + cuid.New()
}
accessKey = hmacStr(login, "access-key")
manifestKey = hmacStr(accessKey, "manifest-key")
if viper.GetBool("print-key") {
fmt.Println("Access key for remote API access: " + accessKey)
}
Expand Down Expand Up @@ -111,7 +113,8 @@ func main() {
w.WriteHeader(404)
return
}
indexb = bytes.Replace(indexb, []byte("{{accessKey}}"), []byte(accessKey), 1)
indexb = bytes.Replace(indexb, []byte("{{accessKey}}"), []byte(accessKey), -1)
indexb = bytes.Replace(indexb, []byte("{{manifestKey}}"), []byte(manifestKey), -1)
w.Header().Set("Content-Type", "text/html")
w.Write(indexb)
return
Expand Down

0 comments on commit efebf3e

Please sign in to comment.