-
Notifications
You must be signed in to change notification settings - Fork 0
/
drive-centric.go
37 lines (29 loc) · 967 Bytes
/
drive-centric.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"fmt"
"net/http"
"net/url"
// drive "github.com/odeke-em/drive/src"
"github.com/odeke-em/meddler"
)
func googleDriveDomainRestrictedQRCode(pl meddler.Payload, res http.ResponseWriter, req *http.Request) {
uri := pl.URI
parsedURL, err := url.Parse(uri)
if err != nil {
http.Error(res, fmt.Sprintf("parseURL %q got %v", uri, err), 500)
return
}
// Uncomment once godep starts working again
// resourceURLStr := drive.DriveResourceEntryURL -- godep is tripping with drive, as of `Sat Oct 31 04:14:35 MDT 2015`
resourceURLStr := "https://drive.google.com"
driveParsedURL, dErr := url.Parse(resourceURLStr)
if dErr != nil {
panic(fmt.Errorf("driveResourceEntryURL %q got %v", resourceURLStr, dErr))
}
if parsedURL.Host != driveParsedURL.Host {
errMsg := fmt.Sprintf("expecting only urls to host %q not %q", driveParsedURL.Host, parsedURL.Host)
http.Error(res, errMsg, 403)
return
}
presentQRCode(pl, res, req)
}