Documentation ¶
Index ¶
- Variables
- func AddUsernameToRequest(req *http.Request, username string) *http.Request
- func CommonInitialize(c CommonConfig)
- func GetQueryInt(req *http.Request, key string) (int, error)
- func GetQueryIntOpt(req *http.Request, key string) (int, bool, error)
- func MysqlInitConfig(config DatabaseConfig) *mysql.Config
- func OpenDatabase(config DatabaseConfig) *sql.DB
- func ReadStrings(rows *sql.Rows) ([]string, error)
- func Username(ctx context.Context) string
- func UsernameMiddleware(next http.Handler) http.Handler
- func WriteErrorFunc(knownErrors map[error]ErrorResponse) func(context.Context, http.ResponseWriter, error) error
- func WriteResponse(ctx context.Context, w http.ResponseWriter, data interface{}) error
- func WriteResponseOrErrorFunc(writeError func(context.Context, http.ResponseWriter, error) error) func(context.Context, http.ResponseWriter, interface{}, error) error
- func WriteServerError(ctx context.Context, w http.ResponseWriter, err error) error
- type CommonConfig
- type DatabaseConfig
- type ErrorResponse
- type HTTPResponse
- type NullBool
- type NullString
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *sql.DB
Functions ¶
func AddUsernameToRequest ¶
func CommonInitialize ¶
func CommonInitialize(c CommonConfig)
func MysqlInitConfig ¶
func MysqlInitConfig(config DatabaseConfig) *mysql.Config
func OpenDatabase ¶
func OpenDatabase(config DatabaseConfig) *sql.DB
func WriteErrorFunc ¶
func WriteErrorFunc(knownErrors map[error]ErrorResponse) func(context.Context, http.ResponseWriter, error) error
func WriteResponse ¶
func WriteResponse(ctx context.Context, w http.ResponseWriter, data interface{}) error
func WriteServerError ¶
Types ¶
type CommonConfig ¶
type CommonConfig struct {
Database DatabaseConfig
}
type DatabaseConfig ¶
type ErrorResponse ¶
type ErrorResponse struct { HTTPCode int `json:"-"` ErrorCode string `json:"error"` Message string `json:"message"` }
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
func (ErrorResponse) StatusCode ¶
func (e ErrorResponse) StatusCode() int
type HTTPResponse ¶
type HTTPResponse interface {
StatusCode() int
}
type NullString ¶
type NullString struct {
sql.NullString
}
func (*NullString) CodecDecodeSelf ¶
func (ns *NullString) CodecDecodeSelf(dec *codec.Decoder)
func (*NullString) CodecEncodeSelf ¶
func (ns *NullString) CodecEncodeSelf(enc *codec.Encoder)
func (NullString) MarshalJSON ¶
func (ns NullString) MarshalJSON() ([]byte, error)
func (*NullString) UnmarshalJSON ¶
func (ns *NullString) UnmarshalJSON(data []byte) error
Click to show internal directories.
Click to hide internal directories.