api

package
v0.4.20 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2018 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

https://github.com/topfreegames/mystack-controller

Licensed under the MIT license: http://www.opensource.org/licenses/mit-license Copyright © 2017 Top Free Games <backend@tfgco.com>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(f http.Handler, middlewares ...Middleware) http.Handler

Chain applies middlewares to a http.HandlerFunc

func CopyConn added in v0.3.0

func CopyConn(dst, src net.Conn)

func GetClusterName

func GetClusterName(r *http.Request) string

GetClusterName gets the name from URL from request

func NewContextWithClusterConfig

func NewContextWithClusterConfig(ctx context.Context, clusterConfig string) context.Context

NewContextWithClusterConfig creates a context with cluster config

func NewContextWithEmail

func NewContextWithEmail(ctx context.Context, email string) context.Context

NewContextWithEmail save email on context

func Proxy added in v0.3.0

func Proxy(remoteConn, clientConn net.Conn, logger logrus.FieldLogger)

func Read added in v0.3.0

func Read(conn net.Conn, logger logrus.FieldLogger) (string, string, error)

func Status

func Status(err error) int

Status return the HTTP status code of an error

func Write

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

Write to the response and with the status code

func WriteBytes

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

WriteBytes to the response and with the status code

Types

type AccessMiddleware

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

AccessMiddleware guarantees that the user is logged

func NewAccessMiddleware added in v0.4.4

func NewAccessMiddleware(app *App) *AccessMiddleware

NewAccessMiddleware is the AccessMiddleware constructor

func (*AccessMiddleware) ServeHTTP

func (m *AccessMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP methods

func (*AccessMiddleware) SetNext

func (m *AccessMiddleware) SetNext(next http.Handler)

SetNext handler

type App

type App struct {
	Address             string
	Config              *viper.Viper
	DB                  models.DB
	Debug               bool
	Logger              logrus.FieldLogger
	Router              *mux.Router
	Server              *http.Server
	EmailDomain         []string
	K8sDomain           string
	Clientset           kubernetes.Interface
	DeploymentReadiness models.Readiness
	JobReadiness        models.Readiness
}

App is our API application

func NewApp

func NewApp(
	host string,
	port int,
	config *viper.Viper,
	debug bool,
	logger logrus.FieldLogger,
	clientset kubernetes.Interface,
) (*App, error)

NewApp ctor

func (*App) ConfigureServer

func (a *App) ConfigureServer()

ConfigureServer construct the routes

func (*App) HandleError

func (a *App) HandleError(w http.ResponseWriter, status int, msg string, err interface{})

HandleError writes an error response with message and status

func (*App) ListenAndServe

func (a *App) ListenAndServe() (io.Closer, error)

ListenAndServe requests

type ClusterConfigHandler

type ClusterConfigHandler struct {
	App    *App
	Method string
}

ClusterConfigHandler handles cluster creation and deletion

func (*ClusterConfigHandler) ServeHTTP

func (c *ClusterConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ClusterHandler

type ClusterHandler struct {
	App    *App
	Method string
}

ClusterHandler handles cluster creation and deletion

func (*ClusterHandler) ServeHTTP

func (c *ClusterHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HealthcheckHandler

type HealthcheckHandler struct {
	App *App
}

HealthcheckHandler handler

func (*HealthcheckHandler) ServeHTTP

func (h *HealthcheckHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method

type LoggingMiddleware

type LoggingMiddleware struct {
	App  *App
	Next http.Handler
}

LoggingMiddleware handles logging

func (*LoggingMiddleware) ServeHTTP

func (m *LoggingMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method

func (*LoggingMiddleware) SetNext

func (m *LoggingMiddleware) SetNext(next http.Handler)

SetNext middleware

type LoginHandler

type LoginHandler struct {
	App    *App
	Method string
}

LoginHandler handles login url requests

func (*LoginHandler) ServeHTTP

func (l *LoginHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method

type Middleware

type Middleware interface {
	SetNext(http.Handler)
	http.Handler
}

Middleware contract

type PayloadMiddleware

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

PayloadMiddleware handles cluster creation and deletion

func (*PayloadMiddleware) ServeHTTP

func (p *PayloadMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*PayloadMiddleware) SetNext

func (p *PayloadMiddleware) SetNext(next http.Handler)

SetNext handler

type UserHandler added in v0.2.0

type UserHandler struct {
	App *App
}

UserHandler handles login url requests

func (*UserHandler) ServeHTTP added in v0.2.0

func (u *UserHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method

type VersionMiddleware

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

VersionMiddleware adds the version to the request

func (*VersionMiddleware) ServeHTTP

func (m *VersionMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP method

func (*VersionMiddleware) SetNext

func (m *VersionMiddleware) SetNext(next http.Handler)

SetNext handler

Jump to

Keyboard shortcuts

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