From c42b2317d6db7ca74141938b3fd7f0213e353e87 Mon Sep 17 00:00:00 2001 From: fancl Date: Fri, 25 Aug 2023 09:53:45 +0800 Subject: [PATCH] add document root --- cmd/main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 1008d96..e6e186f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -4,7 +4,8 @@ import ( "context" "embed" "flag" - "net/http" + "git.nspix.com/golang/kos/entry/http" + httpkg "net/http" "git.nspix.com/golang/kos" ) @@ -16,7 +17,10 @@ type subServer struct { } func (s *subServer) Start(ctx context.Context) (err error) { - kos.Http().Root("/web", http.FS(webDir)) + kos.Http().Root("/web", httpkg.FS(webDir)) + kos.Http().Handle(httpkg.MethodGet, "/hello", func(ctx *http.Context) (err error) { + return ctx.Success("Hello World") + }) return }