Files
athens/pkg/cdn/mongo/getter.go
Aaron Schlesinger b7e15a845c Mongo cdn getter (#62)
* Implementing a MongoDB backed CDN getter

Fixes https://github.com/gomods/athens/issues/49

* removing the base URL from the CDN getter
2018-03-23 13:41:22 -07:00

23 lines
410 B
Go

package mongo
import (
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
)
type getter struct {
conn *mgo.Session
db string
coll string
}
func (g *getter) Get(module string) (string, error) {
coll := g.conn.DB(g.db).C(g.coll)
params := bson.M{"module": module}
entry := Entry{}
if err := coll.Find(params).One(&entry); err != nil {
return "", nil
}
return entry.RedirectURL, nil
}