auth

Paddy 2015-05-11 Parent:8267e1c8bcd1

166:c45b946abe78 Go to Latest

auth/postgres.go

Implement a GetProfileHandler. Create a Handler that will allow us to return details about a Profile. Right now, you only get a single Profile at a time, which is problematic, because it will lead to N+1 requests. But we have no reason to retrieve anyone _else_'s Profile, so it's not like you need to be fetching any Profile other than your own. Also, this requires a Token issued for the Profile in question, which means you're limited to one Profile per request, anyways. Future avenues for exploration may be an admin Token granting access to many Profiles, the unspecified service flow for accessing the API, or simply accepting that name, join date, last active date, and ID are "public information".

History
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 }