shared

package
v0.0.0-...-bde79ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *sql.DB

Db is the global database connection

Functions

func Error

func Error(w http.ResponseWriter, err error, code int)

Error sends an error response

func HandleIDRoute

func HandleIDRoute(w http.ResponseWriter, r *http.Request, selectClause query.Clauser, rowTranslator RowTranslatorFunc, table string)

HandleIDRoute creates a handler function for ID routes

func HandleRoute

func HandleRoute(w http.ResponseWriter, r *http.Request, query query.Clauser, rowTranslator RowTranslatorFunc)

HandleRoute responds to queries

func IgnoreClause

func IgnoreClause(r *http.Request, table string) query.Clauser

IgnoreClause sets up the query to reject certain IDs from the response

func InClause

func InClause(r *http.Request, column string) query.Clauser

InClause creates an IN clause from the request

func InternalError

func InternalError(w http.ResponseWriter, err error)

InternalError sends an internal server error message

func LimitClause

func LimitClause(r *http.Request) query.Clauser

LimitClause creates a limit clause from the request

func MaybeQueryInt

func MaybeQueryInt(r *http.Request, key string) (bool, int)

MaybeQueryInt gets an integer value if available

func QueryInt

func QueryInt(r *http.Request, key string, defaultValue int) int

QueryInt gets an integer value from the request query string

func SearchClause

func SearchClause(r *http.Request) query.Clauser

SearchClause creates a text search clause based on the `name` column

Types

type QueryBuilderFunc

type QueryBuilderFunc func(r *http.Request) query.Clauser

QueryBuilderFunc creates a query for the HTTP request

type RowTranslatorFunc

type RowTranslatorFunc func(rows *sql.Rows) (interface{}, error)

RowTranslatorFunc creates a row of JSON response from a database row

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL