auth
2015-05-11
Parent:8267e1c8bcd1
auth/postgres.go
Support CORS. Add support for the OPTIONS method on certain endpoints. Automatically add headers (and respond to) OPTIONS requests. Note that these headers are full of deceit and mendacity, and we should switch to trout soon so we can actually be honest about what methods we support.
| paddy@148 | 1 package auth |
| paddy@148 | 2 |
| paddy@148 | 3 import ( |
| paddy@148 | 4 "database/sql" |
| paddy@149 | 5 ) |
| paddy@148 | 6 |
| paddy@149 | 7 func NewPostgres(conn string) (postgres, error) { |
| paddy@149 | 8 db, err := sql.Open("postgres", conn) |
| paddy@149 | 9 if err != nil { |
| paddy@149 | 10 return postgres{}, err |
| paddy@149 | 11 } |
| paddy@149 | 12 return postgres{db: db}, nil |
| paddy@149 | 13 } |
| paddy@148 | 14 |
| paddy@148 | 15 type postgres struct { |
| paddy@148 | 16 db *sql.DB |
| paddy@148 | 17 } |