bookshare-backend-api: github.com/misrab/bookshare-backend-api/handlers Index | Files

package handlers

import "github.com/misrab/bookshare-backend-api/handlers"

Index

Package Files

auth.go json.go posts.go readings.go shared.go users.go users_readings.go

Constants

const (
    POST_OFFSET_INCREMENT = "10" // mirrored on client
)
const (
    TOKEN = "lalala"
)

Variables

var (

    // HTTP header defaults
    HEADER_DEFAULTS = map[string]string{
        "Access-Control-Allow-Origin":  "*",
        "Access-Control-Allow-Headers": "Origin,Content-Type,Accept,Authorization",
        "Content-Type":                 "application/json",
        "Access-Control-Allow-Methods": "GET,PATCH,PUT,POST,DELETE",
    }
)

func Atoi64 Uses

func Atoi64(s string) (i int64, err error)

func BasicAuth Uses

func BasicAuth(pass handler) handler

func DecodeAuthHeader Uses

func DecodeAuthHeader(req *http.Request) (string, string, int)

func DeleteItem Uses

func DeleteItem(modelname string, res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func DeletePost Uses

func DeletePost(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func DeleteReading Uses

func DeleteReading(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func DeleteUser Uses

func DeleteUser(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func DeleteUserReading Uses

func DeleteUserReading(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

user from auth

func GetCurrentUser Uses

func GetCurrentUser(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func GetFeedPosts Uses

func GetFeedPosts(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

this could have a recommendatio algo for now most recent. populate with 'user' and 'reading'

func GetPost Uses

func GetPost(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

TODO control viewing based on currentUser and public/private

func GetPosts Uses

func GetPosts(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

TODO control viewing based on currentUser and public/private

func GetReading Uses

func GetReading(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func GetReadings Uses

func GetReadings(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func GetReadingsAutocomplete Uses

func GetReadingsAutocomplete(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func GetUser Uses

func GetUser(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func GetUserFromAuth Uses

func GetUserFromAuth(req *http.Request, dbmap *gorp.DbMap) (error, *models.User)

decodes user creds from auth header and tries to find such user. If no valid match returns nil.

func GetUserReadings Uses

func GetUserReadings(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

get the actual readings

func GetUsers Uses

func GetUsers(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func LoginUser Uses

func LoginUser(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func PatchPost Uses

func PatchPost(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func PatchReading Uses

func PatchReading(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func PatchUser Uses

func PatchUser(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

func PostLinkPreview Uses

func PostLinkPreview(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

example curl:

curl -H "Content-Type: application/json" -X POST -d '{"url":"https://godoc.org/golang.org/x/net/html"}'  localhost:8000/api/v1/link_preview?token=lalala

using post to pass url, which isn't pretty as a query parameter

func PostPost Uses

func PostPost(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

For another model without hooks (i.e. password->hash), would likely want to use parseFormValues.

func PostReading Uses

func PostReading(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

For another model without hooks (i.e. password->hash), would likely want to use parseFormValues.

func PostUser Uses

func PostUser(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

For another model without hooks (i.e. password->hash), would likely want to use parseFormValues.

func PostUserReading Uses

func PostUserReading(res http.ResponseWriter, req *http.Request, dbmap *gorp.DbMap)

For another model without hooks (i.e. password->hash), would likely want to use parseFormValues.

func Respond Uses

func Respond(i interface{}, err error, res http.ResponseWriter)

func Respond401 Uses

func Respond401(res http.ResponseWriter)

func SetHeaders Uses

func SetHeaders(res http.ResponseWriter, code int)

func StringsToInts64 Uses

func StringsToInts64(items ...string) ([]int64, error)

type PostFilled Uses

type PostFilled struct {
    models.Post // original stuff

    Usr models.User    `json:"user"`
    Rdg models.Reading `json:"reading"`
}

type UserAuthWrapper Uses

type UserAuthWrapper struct {
    Email string `json:"email"`
    Hash  string `json:"Hash"`
}

type UserWrapper Uses

type UserWrapper struct {
    Email    string `json:"email"`
    Password string `json:"password"`
}

Package handlers imports 14 packages (graph) and is imported by 1 packages. Updated 2016-08-03. Refresh now. Tools for package owners.