From 1012adefc93a1e2bfe2150b009a541ecb1ea2747 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Mon, 14 Aug 2023 21:56:56 -0700 Subject: [PATCH] initial commits --- requestpath.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 requestpath.go diff --git a/requestpath.go b/requestpath.go new file mode 100644 index 0000000..c6dd3b3 --- /dev/null +++ b/requestpath.go @@ -0,0 +1,32 @@ +package maymoon + +import ( + "sourcecode.social/reiver/go-errhttp" + + "errors" + "net/http" +) + +func requestPath(request *http.Request) (string, error) { + if nil == request { +/////////////// RETURN + return "", errhttp.InternalServerErrorWrap(errors.New("Missing Request")) + } + + var requestpath string + { + uri := request.URL + if nil == uri { +/////////////////////// RETURN + return "", errhttp.InternalServerErrorWrap(errors.New("Missing Internal Request-URI")) + } + + requestpath = uri.Path + if "" == requestpath { +/////////////////////// RETURN + return "", errhttp.BadRequestWrap(errors.New("Bad Path In Request-URI")) + } + } + + return requestpath, nil +}