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

19 lines
298 B
Go
Raw Normal View History

2019-05-27 21:46:09 +00:00
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
}