This repository has been archived on 2019-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
scoreboard/response/web.go
2019-05-27 23:46:09 +02:00

19 lines
313 B
Go

package response
import (
"io"
"net/http"
)
type WebHandlerFunc func() (Page, int)
type Page interface {
Send(w io.Writer)
}
func WebHandler(w http.ResponseWriter, hf WebHandlerFunc) {
page, status := hf()
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(status)
page.Send(w)
}