apiserver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 22 Imported by: 0

README

API server for xene

To build docs for xene apiserver, make sure you have swag installed. The docs are autogenerated from the source code file comments using swagger.

$ go get -u github.com/swaggo/swag/cmd/swag

To build the docs run the following command from the current directory.

$ swag init --generatedTime=false

To view the built API documentation, run xene's api server and open localhost:6060/docs/api/v1/index.html in your browser.

$ xene apiserver -n

$$\   $$\  $$$$$$\  $$$$$$$\   $$$$$$\
\$$\ $$  |$$  __$$\ $$  __$$\ $$  __$$\
 \$$$$  / $$$$$$$$ |$$ |  $$ |$$$$$$$$ |
 $$  $$<  $$   ____|$$ |  $$ |$$   ____|
$$  /\$$\ \$$$$$$$\ $$ |  $$ |\$$$$$$$\
\__/  \__| \_______|\__|  \__| \_______|
INFO[0000] Xene API server is listening on: 127.0.0.1:6060

Being backed by gin-swagger the api client is also generated automatically using go-swagger. Get it from here. To generate the clientset and modeles for apiserver run the following command

$ swagger generate client -f docs/swagger.yaml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewXeneLoggerMiddleware

func NewXeneLoggerMiddleware(logger logrus.FieldLogger, verboseLogs bool) gin.HandlerFunc

NewXeneLoggerMiddleware a gin middleware which can be used a logger, this is used mostly to have a standard logger implementation throughout. We are using logrus logger to log any information in xene.

Types

type APIServer

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

APIServer is the standard type which is used to manage the API exposed by xene.

func NewHTTPSServer

func NewHTTPSServer(host string, port uint32, keyFile, certFile, jwtSecret string,
	disableAuth, verboseLogs bool) *APIServer

NewHTTPSServer returns a new ApiServer capable of running HTTPs server on the specified port.

func NewHTTPServer

func NewHTTPServer(host string, port uint32, disableAuth, verboseLogs bool, jwtSecret string) *APIServer

NewHTTPServer returns the ApiServer configured for running HTTP API server.

func NewUnixSocketServer

func NewUnixSocketServer(file string) *APIServer

NewUnixSocketServer returns the ApiServer configured for running HTTP server on a unix domain socket specified by the file.

func (*APIServer) JWTVerficationMiddleware

func (s *APIServer) JWTVerficationMiddleware(ctx *gin.Context)

JWTVerficationMiddleware is used to authenticate any request for user Sets the ctx 'user' value to the user email

func (*APIServer) NewAPIServerRouter

func (s *APIServer) NewAPIServerRouter(includeLogger bool) *gin.Engine

NewAPIServerRouter returns a new gin router for xene api server. The parameter defines if the router should be initialized with a logger.

func (*APIServer) RunServer

func (s *APIServer) RunServer() error

RunServer runs the server configured for the API. @title Xene API server @version 0.1.0 @description Xene is the workflow creator and manager tool

@contact.name Deepesh Pathak @contact.url https://dpathak.co @contact.email deepeshpathak09@gmail.com

@license.name Apache 2.0 @license.url http://www.apache.org/licenses/LICENSE-2.0.html

@host localhost:6060 @BasePath / @securityDefinitions.basic BasicAuth @securityDefinitions.apikey ApiKeyAuth @in header @name Authorization

func (*APIServer) Shutdown

func (s *APIServer) Shutdown()

Shutdown shuts down the api server running.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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