http

package
v0.0.0-...-a9e947c Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT, Zlib Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrInvalidCredentialsFormat is an error raised when credentials format is not valid
	ErrInvalidCredentialsFormat = whale.Error("Invalid credentials format")
	// ErrInvalidCredentials is an error raised when credentials for a user are invalid
	ErrInvalidCredentials = whale.Error("Invalid credentials")
	// ErrAuthDisabled is an error raised when trying to access the authentication endpoints
	// when the server has been started with the --no-auth flag
	ErrAuthDisabled = whale.Error("Authentication is disabled")
)
View Source
const (
	// ErrInvalidJSON defines an error raised the app is unable to parse request data
	ErrInvalidJSON = whale.Error("Invalid JSON")
	// ErrInvalidRequestFormat defines an error raised when the format of the data sent in a request is not valid
	ErrInvalidRequestFormat = whale.Error("Invalid request data format")
	// ErrInvalidQueryFormat defines an error raised when the data sent in the query or the URL is invalid
	ErrInvalidQueryFormat = whale.Error("Invalid query format")
	// ErrEmptyResponseBody defines an error raised when whale excepts to parse the body of a HTTP response and there is nothing to parse
	ErrEmptyResponseBody = whale.Error("Empty response body")
)
View Source
const API_ROOT string = "https://sparcssso.kaist.ac.kr/api/v2/"
View Source
const (
	// ErrEndpointManagementDisabled is an error raised when trying to access the endpoints management endpoints
	// when the server has been started with the --external-endpoints flag
	ErrEndpointManagementDisabled = whale.Error("Endpoint management is disabled")
)

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, err error, code int, logger *log.Logger)

Error writes an API error message to the response and logger.

Types

type AuthHandler

type AuthHandler struct {
	*mux.Router
	Logger *log.Logger

	UserService     whale.UserService
	CryptoService   whale.CryptoService
	JWTService      whale.JWTService
	EndpointService whale.EndpointService
	// contains filtered or unexported fields
}

AuthHandler represents an HTTP API handler for managing authentication.

func NewAuthHandler

func NewAuthHandler(mw *middleWareService) *AuthHandler

NewAuthHandler returns a new instance of AuthHandler.

type DockerHandler

type DockerHandler struct {
	*mux.Router
	Logger          *log.Logger
	EndpointService whale.EndpointService
	ProxyFactory    ProxyFactory
	// contains filtered or unexported fields
}

DockerHandler represents an HTTP API handler for proxying requests to the Docker API.

func NewDockerHandler

func NewDockerHandler(mw *middleWareService, resourceControlService whale.ResourceControlService) *DockerHandler

NewDockerHandler returns a new instance of DockerHandler.

type EndpointHandler

type EndpointHandler struct {
	*mux.Router
	Logger *log.Logger

	EndpointService whale.EndpointService
	FileService     whale.FileService
	// contains filtered or unexported fields
}

EndpointHandler represents an HTTP API handler for managing Docker endpoints.

func NewEndpointHandler

func NewEndpointHandler(mw *middleWareService) *EndpointHandler

NewEndpointHandler returns a new instance of EndpointHandler.

type FileHandler

type FileHandler struct {
	http.Handler
}

FileHandler represents an HTTP API handler for managing static files.

func (*FileHandler) ServeHTTP

func (fileHandler *FileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Handler

type Handler struct {
	AuthHandler      *AuthHandler
	UserHandler      *UserHandler
	EndpointHandler  *EndpointHandler
	SettingsHandler  *SettingsHandler
	TemplatesHandler *TemplatesHandler
	DockerHandler    *DockerHandler
	WebSocketHandler *WebSocketHandler
	UploadHandler    *UploadHandler
	FileHandler      *FileHandler
}

Handler is a collection of all the service handlers.

func (*Handler) ServeHTTP

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

ServeHTTP delegates a request to the appropriate subhandler.

type ProxyFactory

type ProxyFactory struct {
	ResourceControlService whale.ResourceControlService
}

ProxyFactory is a factory to create reverse proxies to Docker endpoints

type SSOClient

type SSOClient struct {
	ClientID  string
	SecretKey string
}

func NewSSOClient

func NewSSOClient(clientID string, secretKey string) *SSOClient

func (SSOClient) DoUnregister

func (s SSOClient) DoUnregister(sid string) (bool, error)

func (SSOClient) GetLoginParams

func (s SSOClient) GetLoginParams() (*SSOLoginParams, error)

func (SSOClient) GetLogoutURI

func (s SSOClient) GetLogoutURI(sid string, redirectURI string) (string, error)

func (SSOClient) GetUserInfo

func (s SSOClient) GetUserInfo(code string) (map[string]interface{}, error)

type SSOLoginParams

type SSOLoginParams struct {
	URI   string
	State string
}

type Server

type Server struct {
	BindAddress            string
	AssetsPath             string
	AuthDisabled           bool
	SSOID                  string
	SSOKey                 string
	EndpointManagement     bool
	UserService            whale.UserService
	EndpointService        whale.EndpointService
	ResourceControlService whale.ResourceControlService
	CryptoService          whale.CryptoService
	JWTService             whale.JWTService
	FileService            whale.FileService
	Settings               *whale.Settings
	TemplatesURL           string
	Handler                *Handler
}

Server implements the whale.Server interface

func (*Server) Start

func (server *Server) Start() error

Start starts the HTTP server

type SettingsHandler

type SettingsHandler struct {
	*mux.Router
	Logger *log.Logger
	// contains filtered or unexported fields
}

SettingsHandler represents an HTTP API handler for managing settings.

func NewSettingsHandler

func NewSettingsHandler(mw *middleWareService) *SettingsHandler

NewSettingsHandler returns a new instance of SettingsHandler.

type TemplatesHandler

type TemplatesHandler struct {
	*mux.Router
	Logger *log.Logger
	// contains filtered or unexported fields
}

TemplatesHandler represents an HTTP API handler for managing templates.

func NewTemplatesHandler

func NewTemplatesHandler(mw *middleWareService) *TemplatesHandler

NewTemplatesHandler returns a new instance of TemplatesHandler.

type UploadHandler

type UploadHandler struct {
	*mux.Router
	Logger      *log.Logger
	FileService whale.FileService
}

UploadHandler represents an HTTP API handler for managing file uploads.

func NewUploadHandler

func NewUploadHandler(mw *middleWareService) *UploadHandler

NewUploadHandler returns a new instance of UploadHandler.

type UserHandler

type UserHandler struct {
	*mux.Router
	Logger                 *log.Logger
	UserService            whale.UserService
	ResourceControlService whale.ResourceControlService
	CryptoService          whale.CryptoService
}

UserHandler represents an HTTP API handler for managing users.

func NewUserHandler

func NewUserHandler(mw *middleWareService) *UserHandler

NewUserHandler returns a new instance of UserHandler.

type WebSocketHandler

type WebSocketHandler struct {
	*mux.Router
	Logger          *log.Logger
	EndpointService whale.EndpointService
}

WebSocketHandler represents an HTTP API handler for proxying requests to a web socket.

func NewWebSocketHandler

func NewWebSocketHandler() *WebSocketHandler

NewWebSocketHandler returns a new instance of WebSocketHandler.

Jump to

Keyboard shortcuts

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