This repository has been archived on 2019-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
scoreboard/service/id/id.go
2019-05-27 23:46:09 +02:00

18 lines
298 B
Go

package id
import (
"net/http"
"go.mongodb.org/mongo-driver/bson/primitive"
"github.com/go-chi/chi"
)
func ParseFromRequest(r *http.Request) (*primitive.ObjectID, error) {
id, err := primitive.ObjectIDFromHex(chi.URLParam(r, "id"))
if err != nil {
return nil, err
}
return &id, nil
}