http

package
v0.0.0-...-3c05ffe Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2018 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(onerr func(c *gin.Context)) gin.HandlerFunc

AuthMiddleware middleware to check auth token

func BasicMiddleware

func BasicMiddleware() gin.HandlerFunc

BasicMiddleware middleware of gin to handler OPTIONS and cors

Types

type HTTPServer

type HTTPServer struct {
	Config *db.SparrowConfig
	// contains filtered or unexported fields
}

HTTPServer holds HTTP server configuration and routes

func NewHTTPServer

func NewHTTPServer(config *db.SparrowConfig, dbm *db.DBManager) HTTPServer

NewHTTPServer returns new HTTPServer

func (*HTTPServer) Start

func (httpServer *HTTPServer) Start()

Start starts HTTP server listener

func (*HTTPServer) Stop

func (httpServer *HTTPServer) Stop()

Stop stops HTTP server listener

type Response

type Response struct {
	Database string                 `json:"database"`
	Content  map[string]interface{} `json:"content"`
	Error    []string               `json:"error"`
}

Response HTTP response

func NewResponse

func NewResponse() *Response

NewResponse returns new Response

func (*Response) AddContent

func (r *Response) AddContent(key string, val interface{})

AddContent adds object to query return values

func (*Response) AddError

func (r *Response) AddError(err error)

AddError adds error message

func (*Response) AddErrorStr

func (r *Response) AddErrorStr(text string)

AddErrorStr adds error message as string

func (*Response) Value

func (r *Response) Value() []byte

Value returns query result as json

type ServeHandler

type ServeHandler struct {
	// contains filtered or unexported fields
}

ServeHandler holds main http methods

func NewServeHandler

func NewServeHandler(dbm *db.DBManager) *ServeHandler

NewServeHandler returns new ServeHandler

Jump to

Keyboard shortcuts

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