cycapi

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 16 Imported by: 0

README

cyclops-api

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SentryEnabled = false

Functions

func Error

func Error(err error)

func SentryInit added in v1.2.2

func SentryInit(dsn, environment string)

func StartServer

func StartServer(address string, handler http.Handler)

StartServer starts a simple http server

func StartTLSServer

func StartTLSServer(address string, handler http.Handler, certFile, keyFile string)

StartTLSServer starts a TLS server with provided TLS cert and key files

Types

type Context

type Context struct {
	context.Context
	Response  http.ResponseWriter
	Request   *http.Request
	Params    url.Values
	Data      *sync.Map
	SpanRoot  *sentry.Span
	RouteInfo struct {
		VersionName     string
		ResourceName    string
		ResourceID      string
		SubresourceName string
		SubresourceID   string
		Method          string
		CustomMethod    string
	}
	// contains filtered or unexported fields
}

func NewContext

func NewContext(res http.ResponseWriter, req *http.Request) *Context

func (*Context) BadRequest

func (ctx *Context) BadRequest()

func (*Context) Close

func (ctx *Context) Close()

func (*Context) HubBreadcrumb

func (ctx *Context) HubBreadcrumb(category, msg string, data map[string]interface{})

func (*Context) HubError

func (ctx *Context) HubError(err error)

func (*Context) HubMessage

func (ctx *Context) HubMessage(msg string)

func (*Context) InternalServerError

func (ctx *Context) InternalServerError(err error)

func (*Context) MethodNotAllowed

func (ctx *Context) MethodNotAllowed()

func (*Context) NoContent

func (ctx *Context) NoContent()

func (*Context) NotFound

func (ctx *Context) NotFound()

func (*Context) Ok

func (ctx *Context) Ok()

func (*Context) SendError

func (ctx *Context) SendError(error error, status int)

func (*Context) SendSuccess

func (ctx *Context) SendSuccess(body interface{})

func (*Context) SetTag

func (ctx *Context) SetTag(key, value string)

func (*Context) Unauthorized

func (ctx *Context) Unauthorized()

func (*Context) UnprocessableEntity

func (ctx *Context) UnprocessableEntity()

type HandlerFunc

type HandlerFunc func(*Context)

func (HandlerFunc) ServeHTTP

func (f HandlerFunc) ServeHTTP(context *Context)

type MongoConn

type MongoConn struct {
	Conn *mongo.Client
}

func CreateMongoConnection

func CreateMongoConnection(driver, username, password, url string) (*MongoConn, error)

CreateMongoConnection Creates a DB Connection with the Database specified on the url

func (*MongoConn) CloseConnection

func (db *MongoConn) CloseConnection() error

CloseConnection Closes a DB Connection

type MysqlConn

type MysqlConn struct {
	Conn *sql.DB
}

func CreateMysqlConnection

func CreateMysqlConnection(host string, username string, password string, dbname string) (DB *MysqlConn, err error)

func (*MysqlConn) CloseConnection

func (db *MysqlConn) CloseConnection() error

CloseConnection Closes a DB Connection

func (*MysqlConn) Query

func (db *MysqlConn) Query(query string, args interface{}) (rows *sql.Rows, err error)

func (*MysqlConn) QueryRow

func (db *MysqlConn) QueryRow(query string, args interface{}) (row *sql.Row)

type Routes

type Routes struct {
	Map map[string]version
}
var Router *Routes

func (*Routes) AddResource

func (r *Routes) AddResource(name string, versionName string, handler HandlerFunc)

func (*Routes) AddSubresource

func (r *Routes) AddSubresource(name string, version string, resourceName string, handler HandlerFunc)

func (*Routes) AddVersion

func (r *Routes) AddVersion(name string)

func (*Routes) ServeHTTP

func (r *Routes) ServeHTTP(w http.ResponseWriter, req *http.Request)

Main entry point for each call

Jump to

Keyboard shortcuts

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