Skip to content

HTTP Handler

Maxence Charriere edited this page Feb 23, 2020 · 19 revisions

Table of Contents

Description

The HTTP handler is what is serving a progressive web app and its resources:

  • app.wasm: The web assembly binary built with GOARCH=wasm GOOS=js go build -o app.wasm
  • app.js: The JavaScript file that load the web assembly binary and initialize service workers
  • app-worker.js: a JavaScript support file required by Go wasm programs to run
  • manifest.json: A simple JSON file that tells the browser about a web app and how it should behave when 'installed' on the user's mobile device or desktop
  • app.css: A CSS file that contains the package default styles
  • CSS files: The styles used by the app
  • JavaScript files: Thes scripts used by the app
  • Other static resources: Images, fonts, sounds, ...

It is used in servers or cloud functions.

Usage

The HTTP handler is implemented in the app.Handler struct. All its fields are about set up app data such as:

  • Title
  • Metadata
  • Icons
  • CSS files
  • JavaScript files
  • PWA manifest data

Example:

h := &app.Handler{
    Name:        "Luck",
    Author:      "Maxence Charriere",
    Description: "Lottery numbers generator.",
    Icon: app.Icon{
        Default: "/web/icon.png",
    },
    Keywords: []string{
        "EuroMillions",
        "MEGA Millions",
        "Powerball",
    },
    ThemeColor:      "#000000",
    BackgroundColor: "#000000",
    Styles: []string{
        "/web/luck.css",
    },
    Version: "wIKiverSiON",
}
Clone this wiki locally