mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
* Implementing a MongoDB backed CDN getter Fixes https://github.com/gomods/athens/issues/49 * removing the base URL from the CDN getter
23 lines
410 B
Go
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
|
|
}
|