forked from WEB-IMB-WS2526/lab-development-imb
27 lines
491 B
Go
27 lines
491 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
type appleHandler int
|
|
type bananaHandler string
|
|
|
|
func (a appleHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
fmt.Fprintln(w, "Apple 🍎")
|
|
}
|
|
|
|
func (b bananaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
fmt.Fprintln(w, "Banana 🍌")
|
|
}
|
|
|
|
func main() {
|
|
var a appleHandler
|
|
var b bananaHandler
|
|
mux := http.NewServeMux()
|
|
mux.Handle("/apple", a)
|
|
mux.Handle("/banana", b)
|
|
http.ListenAndServe("localhost:8080", mux)
|
|
}
|