Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example handler #40

Open
fardok opened this issue Feb 22, 2018 · 1 comment
Open

example handler #40

fardok opened this issue Feb 22, 2018 · 1 comment

Comments

@fardok
Copy link

fardok commented Feb 22, 2018

can somebody write any example handler for update?

func updateHandler(w http.ResponseWriter, r *http.Request){

file, err := os.Open("myprogram.exe")

etc....

}

@mozey
Copy link

mozey commented Jan 14, 2021

The server could implement a handler as below

func update(w http.ResponseWriter, r *http.Request) {
  http.ServeFile(w, r, filepath.Join("path", "to", "myprogram.exe"))
}
...
http.HandleFunc("/update", update)

Given the doUpdate func as per the README.md, the client might then update itself like this

if *updateFlag {
  err := doUpdate("http://localhost/update")
  if err != nil {
    fmt.Println(err)
    os.Exit(1)
  }
  os.Exit(0)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants