Isn't it time to make a PWA?

Viewed 227
package main

import (
	"fmt"
	"net/http"
)

func main() {
	mux := http.NewServeMux()

	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, `<html>
<head>
    <title>My Golang Website</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="manifest" href="/manifest.json">    
</head>
<body>
    <h1>Welcome to my website!</h1>
</body> 
</html>`)
	})

	mux.HandleFunc("/manifest.json", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, `{
  "name": "My Golang Website",
  "short_name": "Golang Website",
  "start_url": "/",
  "display": "standalone",
  "background_color": "#FFF",
  "theme_color": "#FFF"
}`)
	})

	fmt.Println("Server is listening on port 3000")
	http.ListenAndServe(":3000", mux)
}
0 Answers