init
This commit is contained in:
21
internal/server/request/request.go
Normal file
21
internal/server/request/request.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Param(r *http.Request, name string) (uint64, error) {
|
||||
idStr := r.PathValue(name)
|
||||
id, err := strconv.ParseUint(idStr, 10, 64)
|
||||
|
||||
if err != nil {
|
||||
return id, err
|
||||
}
|
||||
|
||||
if id < 1 {
|
||||
return id, err
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
||||
Reference in New Issue
Block a user