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

20 lines
313 B
Go
Raw Normal View History

2019-05-27 21:46:09 +00:00
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)
}