| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | ) |
| 7 | |
| 8 | var version string = "1.0" |
| 9 | |
| 10 | type Middleware struct { |
| 11 | Name string |
| 12 | } |
| 13 | |
| 14 | func (m *Middleware) Handler(w http.ResponseWriter, r *http.Request) { |
| 15 | fmt.Fprintln(w, "Welcome to my website", m.Name, version) |
| 16 | } |
| 17 | |
| 18 | func main() { |
| 19 | m := &Middleware{"Test"} |
| 20 | http.HandleFunc("/", m.Handler) |
| 21 | http.ListenAndServe(":8080", nil) |
| 22 | } |