Start work on populating context of communication at API layer
Remove communication stub, it's a performance enhancement.
This commit is contained in:
parent
266004624d
commit
e569bb32b7
9 changed files with 331 additions and 119 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
|
@ -19,6 +20,18 @@ func NewRouter(r *mux.Router) *router {
|
|||
router: r,
|
||||
}
|
||||
}
|
||||
func (r *router) IDFromMux(req *http.Request) (int, *nhttp.ErrorWithStatus) {
|
||||
vars := mux.Vars(req)
|
||||
comm_id_str := vars["id"]
|
||||
if comm_id_str == "" {
|
||||
return 0, nhttp.NewBadRequest("no id provided")
|
||||
}
|
||||
comm_id, err := strconv.Atoi(comm_id_str)
|
||||
if err != nil {
|
||||
return 0, nhttp.NewBadRequest("can't turn report ID into an int: %w", err)
|
||||
}
|
||||
return comm_id, nil
|
||||
}
|
||||
func (r *router) IDFromURI(route string, uri string) (*int, error) {
|
||||
var match mux.RouteMatch
|
||||
req, _ := http.NewRequest("GET", uri, nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue