go-web/main.go

28 lines
436 B
Go
Raw Normal View History

2024-09-05 14:23:58 +00:00
package main
import (
"fmt"
"html"
"log"
"net/http"
2024-09-05 15:30:59 +00:00
"git.vinchent.xyz/vinchent/go-web/framework"
2024-09-05 14:23:58 +00:00
)
type FooHandler struct{}
func (foo FooHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
}
func main() {
2024-09-05 15:30:59 +00:00
server := &http.Server{
Addr: ":8080",
Handler: framework.NewCore(),
}
2024-09-05 14:23:58 +00:00
2024-09-05 15:30:59 +00:00
if err := server.ListenAndServe(); err != nil {
log.Panic(err)
}
2024-09-05 14:23:58 +00:00
}