1
0

Added ServeStatic() method. GetURLParams now returns parameter itself, and renamed to GetURLParam.

This commit is contained in:
Alexander Andreev 2022-02-06 15:24:37 +04:00
parent 8341fba20f
commit 5f9485fe3c
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -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 {