Back to

Package api

Latest Go to latest

The latest major version is .

Published: Jun 10, 2020 | License: Apache-2.0 | Module:


Package BlackSpace Backend API.

This serves as the user's microservice api definition for the BlackSpace Platform

Terms Of Service:

there are no TOS at this moment, use at your own risk we take no responsibility

Schemes: http, https
Host: localhost
BasePath: /v1
Version: 1.0.0
License: MIT
Contact: Yoan Yomba<>

- application/json

- application/json

- api_key:

x-meta-value: value
  - value1
  - value2
  - name: obj
    value: field



type ArrayResponse

type ArrayResponse []string

type Config

type Config struct {
	HttpClientTimeout         time.Duration `mapstructure:"http-client-timeout"`
	HttpServerTimeout         time.Duration `mapstructure:"http-server-timeout"`
	HttpServerShutdownTimeout time.Duration `mapstructure:"http-server-shutdown-timeout"`
	BackendURL                []string      `mapstructure:"backend-url"`
	UILogo                    string        `mapstructure:"ui-logo"`
	UIMessage                 string        `mapstructure:"ui-message"`
	UIColor                   string        `mapstructure:"ui-color"`
	UIPath                    string        `mapstructure:"ui-path"`
	DataPath                  string        `mapstructure:"data-path"`
	ConfigPath                string        `mapstructure:"config-path"`
	Port                      string        `mapstructure:"port"`
	PortMetrics               int           `mapstructure:"port-metrics"`
	Hostname                  string        `mapstructure:"hostname"`
	RandomDelay               bool          `mapstructure:"random-delay"`
	RandomError               bool          `mapstructure:"random-error"`
	JWTSecret                 string        `mapstructure:"jwt-secret"`
	JWTSigningAuthority       string        `mapstructure:"JWT_SIGNER"`
	IsProduction              bool          `mapstructure:"IS_PRODUCTION"`

type DeleteUserByIdRequest

type DeleteUserByIdRequest struct {
	// id of the user account to delete
	// in: query
	// required: true
	Id uint32 `json:"result"`

Delete user by id request swagger:parameters deleteUser

type FluxConfig

type FluxConfig struct {
	GitUrl    string `mapstructure:"git-url"`
	GitBranch string `mapstructure:"git-branch"`

type GetUserRequestSwagger

type GetUserRequestSwagger struct {
	// user account to create
	// in: body
	Body struct {
		// id of the user account to get
		// in: query
		// required: true
		Id uint32 `json:"result"`

Get user by id request swagger:parameters getUserRequest

type GetUserResponse

type GetUserResponse struct {
	User  models.UserORM `json:"user"`
	Error error          `json:"error"`

type GetUserResponseSwagger

type GetUserResponseSwagger struct {
	// in: body
	Body struct {
		// error
		// required: true
		// example: error occured while processing request
		Error error `json:"error"`
		// User
		// required: true
		User models.UserORM `json:"user"`

Common operation response swagger:response getUserResponse

type LoggingMiddleware

type LoggingMiddleware struct {
	// contains filtered or unexported fields

func NewLoggingMiddleware

func NewLoggingMiddleware(logger *zap.Logger) *LoggingMiddleware

func (*LoggingMiddleware) Handler

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

type LoginResponse

type LoginResponse struct {
	JwtToken string `json:"token"`
	Error    error  `json:"error"`

type LoginUserRequest

type LoginUserRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`

type MapResponse

type MapResponse map[string]string

type OperationResponse

type OperationResponse struct {
	Error error `json:"error"`

type OperationResponseSwagger

type OperationResponseSwagger struct {
	// in: body
	Body struct {
		// error
		// required: true
		// example: error occured while processing request
		Error error `json:"error"`

Common operation response swagger:response operationResponse

type PrometheusMiddleware

type PrometheusMiddleware struct {
	Histogram *prometheus.HistogramVec
	Counter   *prometheus.CounterVec

func NewPrometheusMiddleware

func NewPrometheusMiddleware() *PrometheusMiddleware

func (*PrometheusMiddleware) Handler

func (p *PrometheusMiddleware) Handler(next http.Handler) http.Handler

Metrics godoc @Summary Prometheus metrics @Description returns HTTP requests duration and Go runtime metrics @Tags Kubernetes @Produce plain @Router /metrics [get] @Success 200 {string} string "OK"

type RuntimeResponse

type RuntimeResponse struct {
	Hostname     string `json:"hostname"`
	Version      string `json:"version"`
	Revision     string `json:"revision"`
	Color        string `json:"color"`
	Logo         string `json:"logo"`
	Message      string `json:"message"`
	GOOS         string `json:"goos"`
	GOARCH       string `json:"goarch"`
	Runtime      string `json:"runtime"`
	NumGoroutine string `json:"num_goroutine"`
	NumCPU       string `json:"num_cpu"`

type Server

type Server struct {
	Auth      *authentication.Authentication
	JwtConfig *authentication.JwtConfiguration
	Keys      *authentication.JsonKeys
	// contains filtered or unexported fields

func NewMockServer

func NewMockServer() *Server

func NewServer

func NewServer(config *Config, logger *zap.Logger, db *database.Db, authServiceWrapper *authentication.Authentication) (*Server, error)

func (*Server) ErrorResponse

func (s *Server) ErrorResponse(w http.ResponseWriter, r *http.Request, error string, code int)

func (*Server) ExtractJwtFromHeader

func (s *Server) ExtractJwtFromHeader(r *http.Request) (*utils.TokenValidationResponse, error)

func (*Server) ExtractJwtFromRequest

func (s *Server) ExtractJwtFromRequest(w http.ResponseWriter, r *http.Request) (uint32, error)

func (*Server) GenerateAndSignJwtToken

func (s *Server) GenerateAndSignJwtToken(userID uint32, user *models.UserORM) (string, error)

func (*Server) JSONResponse

func (s *Server) JSONResponse(w http.ResponseWriter, r *http.Request, result interface{})

func (*Server) JSONResponseCode

func (s *Server) JSONResponseCode(w http.ResponseWriter, r *http.Request, result interface{}, responseCode int)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(stopCh <-chan struct{})

func (*Server) SignUpHandler

func (s *Server) SignUpHandler(w http.ResponseWriter, r *http.Request)

swagger:route POST /v1/user/signup User signUpUserReq

Sign Up User

creates a user account object in the backend database

- application/json
- application/x-protobuf

- application/json
- application/x-protobuf

Schemes: http, https, ws, wss

  oauth: read, write


200: signUpUserResp

400: badRequestError 404: notFoundError 403: forbiddenError 406: genericError 500: internalServerError creates a user account

func (*Server) UserExistsToAuthService

func (s *Server) UserExistsToAuthService(w http.ResponseWriter, user *models.UserORM) bool

UserExistsToAuthService checks with the authentication wether a user exists or not

type SignUpUserRequest

type SignUpUserRequest struct {
	Email     string `json:"email"`
	Username  string `json:"username"`
	Password  string `json:"password"`
	Firstname string `json:"firstname"`
	Lastname  string `json:"lastname"`

type SignUpUserResponse

type SignUpUserResponse struct {
	Error    error  `json:"error"`
	Id       uint32 `json:"id"`
	JwtToken string `json:"jwt"`

type UpdateUserRequest

type UpdateUserRequest struct {
	User models.User

type UpdateUserRequestSwagger

type UpdateUserRequestSwagger struct {
	// user account to create
	// in: body
	Body struct {
		// user to update
		// required: true
		User models.User `json:"result"`
	// user id of account to update
	// in: query
	UserAccountId uint32

Update user request swagger:parameters updateUser

type UpdateUserResponse

type UpdateUserResponse struct {
	Error error

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier