api

package
v0.0.0-...-0d2f101 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2018 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w http.ResponseWriter, status int, text string)

Write to response with status code

func WriteBytes

func WriteBytes(w http.ResponseWriter, status int, text []byte)

WriteBytes to the response and with the status code

func WriteError

func WriteError(w http.ResponseWriter, status int, errorMsg string, err error)

WriteError to the response with message and log error message

func WriteErrorWithJSON

func WriteErrorWithJSON(w http.ResponseWriter, status int, res []byte, msg string)

WriteErrorWithJSON sends a response with status error and log error msg

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, body map[string]interface{})

WriteJSON to the response and with the status code

func WriteSuccessWithJSON

func WriteSuccessWithJSON(w http.ResponseWriter, status int, res []byte, msg string)

WriteSuccessWithJSON sends response with statusOK to request and log success msg

Types

type App

type App struct {
	Address string
	Router  *mux.Router
	Server  *http.Server
	Logger  logrus.FieldLogger
	Config  *viper.Viper
}

App struct

func NewApp

func NewApp(
	host string,
	port int,
	config *viper.Viper,
) (*App, error)

NewApp constructor

func (*App) GetRemoteDocsRoute

func (a *App) GetRemoteDocsRoute() string

GetRemoteDocsRoute gets the route for the autodoc handler

func (*App) GetRemoteProtosRoute

func (a *App) GetRemoteProtosRoute() string

GetRemoteProtosRoute gets the route for the protos handler

func (*App) Init

func (a *App) Init()

Init starts the app

type DocsHandler

type DocsHandler struct {
	App *App
}

DocsHandler handle documentation routes

func NewDocsHandler

func NewDocsHandler(a *App) *DocsHandler

NewDocsHandler create new docs handler

func (*DocsHandler) ServeHTTP

func (s *DocsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method. Docs will only work if server has a remote for autodoc

type KickMsg

type KickMsg struct {
	Uids         []string
	FrontendType string
}

KickMsg post

type KickUserHandler

type KickUserHandler struct {
	App *App
}

KickUserHandler handle kick route

func NewKickUserHandler

func NewKickUserHandler(a *App) *KickUserHandler

NewKickUserHandler creates a new kick user handler

func (*KickUserHandler) ServeHTTP

func (s *KickUserHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PushMsg

type PushMsg struct {
	Uids         []string
	Route        string
	Message      interface{}
	FrontendType string
}

PushMsg post

type PushToUsersHandler

type PushToUsersHandler struct {
	App *App
}

PushToUsersHandler handle push route

func NewPushToUsersHandler

func NewPushToUsersHandler(a *App) *PushToUsersHandler

NewPushToUsersHandler creates a new push to users handler

func (*PushToUsersHandler) ServeHTTP

func (s *PushToUsersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method

type RPCHandler

type RPCHandler struct {
	App *App
}

RPCHandler handles RPC routes

func NewRPCHandler

func NewRPCHandler(a *App) *RPCHandler

NewRPCHandler creates a new handler

func (*RPCHandler) ServeHTTP

func (s *RPCHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method

type RequestHandler

type RequestHandler struct {
	App *App
	// contains filtered or unexported fields
}

RequestHandler handle requests

func NewRequestHandler

func NewRequestHandler(a *App) *RequestHandler

NewRequestHandler creates a new request handler

func (*RequestHandler) ServeHTTP

func (s *RequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP creates a web socket connection with the user

type ServersHandler

type ServersHandler struct {
	App *App
}

ServersHandler handle list server routes

func NewServersHandler

func NewServersHandler(a *App) *ServersHandler

NewServersHandler creates a new servers handler

func (*ServersHandler) ServeHTTP

func (s *ServersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method

Jump to

Keyboard shortcuts

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