From 5f9485fe3c001a246ab8a410c83f38e50a2b65f4 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 6 Feb 2022 15:24:37 +0400 Subject: [PATCH] Added ServeStatic() method. GetURLParams now returns parameter itself, and renamed to GetURLParam. --- pkg/server/http.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/server/http.go b/pkg/server/http.go index 3ed56a7..61846d9 100644 --- a/pkg/server/http.go +++ b/pkg/server/http.go @@ -49,9 +49,13 @@ func (s *HttpServer) DELETE(path string, handler http.HandlerFunc) { s.router.Handler(http.MethodDelete, path, handler) } -// GetURLParams wrapper around underlying router for getting URL parameters. -func GetURLParams(r *http.Request) httprouter.Params { - return httprouter.ParamsFromContext(r.Context()) +func (s *HttpServer) ServeStatic(path string, fsys http.FileSystem) { + s.router.ServeFiles(path, fsys) +} + +// GetURLParam wrapper around underlying router for getting URL parameters. +func GetURLParam(r *http.Request, param string) string { + return httprouter.ParamsFromContext(r.Context()).ByName(param) } func (s *HttpServer) Start(network, address string) error {