19 lines
313 B
Go
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)
|
|
}
|