web

package
v0.0.0-...-5815c09 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package web provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.12.2 DO NOT EDIT.

Index

Constants

View Source
const (
	JwtAuthScopes = "jwtAuth.Scopes"
)

Variables

This section is empty.

Functions

func ConfigureHTTPServers

func ConfigureHTTPServers(lifecycle fx.Lifecycle, shutdowner fx.Shutdowner, k *koanf.Koanf) (*echo.Echo, error)

ConfigureHTTPServers creates an HTTP server with standard middleware and a system HTTP server with health and metrics endpoints returns the echo engine for serving API

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type Channel

type Channel struct {
	Id         string   `json:"id"`
	Members    []string `json:"members"`
	Name       string   `json:"name"`
	OwnerId    string   `json:"ownerId"`
	Visibility string   `json:"visibility"`
}

Channel defines model for Channel.

type ChannelCreation

type ChannelCreation struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

ChannelCreation defines model for ChannelCreation.

type ChannelCreationRequest

type ChannelCreationRequest = ChannelCreation

ChannelCreationRequest defines model for ChannelCreationRequest.

type ChannelSubscription

type ChannelSubscription = map[string]interface{}

ChannelSubscription defines model for ChannelSubscription.

type ChannelSubscriptionRequest

type ChannelSubscriptionRequest = ChannelSubscription

ChannelSubscriptionRequest defines model for ChannelSubscriptionRequest.

type ChattyService

type ChattyService interface {
	Signup(username string, password string) (string, string, error)
	Login(username string, password string) (string, error)
	GetUsers() ([]*inmemory.UserBean, error)
	CreateChannel(name string, visibility string, owner string) (*inmemory.ChannelBean, error)
	SubscribeChannel(username string, channelName string) error
	GetChannels() ([]*inmemory.ChannelBean, error)
	HandleConnection(ctx echo.Context) error
	GetConnectionToken(ctx echo.Context, userId string) (string, error)
}

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type ErrorMessage

type ErrorMessage struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorMessage defines model for ErrorMessage.

type HTTPServerConfig

type HTTPServerConfig struct {
	Address                string                  `json:"address"`
	SystemHTTPServerConfig *SystemHTTPServerConfig `json:"system,omitempty"`
	ReadTimeout            time.Duration           `json:"readTimeout"`
	WriteTimeout           time.Duration           `json:"writeTimeout"`
	IdleTimeout            time.Duration           `json:"idleTimeout"`
}

HTTPServerConfig provides configuration for HTTP Server

func ReadHTTPServerConfig

func ReadHTTPServerConfig(k *koanf.Koanf) (*HTTPServerConfig, error)

ReadHTTPServerConfig reads HTTP server configuration

type LoginRequest

type LoginRequest = LoginSchema

LoginRequest defines model for LoginRequest.

type LoginSchema

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

LoginSchema defines model for LoginSchema.

type N200SuccessChannelSubscribe

type N200SuccessChannelSubscribe = SuccessChannelSubscription

N200SuccessChannelSubscribe defines model for 200SuccessChannelSubscribe.

type N200SuccessGetChannels

type N200SuccessGetChannels = SuccessGetChannels

N200SuccessGetChannels defines model for 200SuccessGetChannels.

type N200SuccessGetUsers

type N200SuccessGetUsers = SuccessGetUsers

N200SuccessGetUsers defines model for 200SuccessGetUsers.

type N200SuccessLogin

type N200SuccessLogin = SuccessLoginSchema

N200SuccessLogin defines model for 200SuccessLogin.

type N200SuccessWsConnection

type N200SuccessWsConnection = SuccessWsConnectionSchema

N200SuccessWsConnection defines model for 200SuccessWsConnection.

type N200SuccessWsToken

type N200SuccessWsToken = SuccessLoginSchema

N200SuccessWsToken defines model for 200SuccessWsToken.

type N201SuccessChannelCreation

type N201SuccessChannelCreation = SuccessChannelCreation

N201SuccessChannelCreation defines model for 201SuccessChannelCreation.

type N201SuccessSignUp

type N201SuccessSignUp = SuccessSignupSchema

N201SuccessSignUp defines model for 201SuccessSignUp.

type N400BadRequest

type N400BadRequest = ErrorMessage

N400BadRequest defines model for 400BadRequest.

type N401UnauthorizedError

type N401UnauthorizedError = UnauthorizedSchema

N401UnauthorizedError defines model for 401UnauthorizedError.

type N500InternalServerError

type N500InternalServerError = ErrorMessage

N500InternalServerError defines model for 500InternalServerError.

type PublicPostChannelsJSONRequestBody

type PublicPostChannelsJSONRequestBody = ChannelCreation

PublicPostChannelsJSONRequestBody defines body for PublicPostChannels for application/json ContentType.

type PublicPostChannelsSubscribeJSONRequestBody

type PublicPostChannelsSubscribeJSONRequestBody = ChannelSubscription

PublicPostChannelsSubscribeJSONRequestBody defines body for PublicPostChannelsSubscribe for application/json ContentType.

type PublicPostSignupJSONRequestBody

type PublicPostSignupJSONRequestBody = SignUpSchema

PublicPostSignupJSONRequestBody defines body for PublicPostSignup for application/json ContentType.

type PublicPostTokenJSONRequestBody

type PublicPostTokenJSONRequestBody = LoginSchema

PublicPostTokenJSONRequestBody defines body for PublicPostToken for application/json ContentType.

type ServerInterface

type ServerInterface interface {
	// Returns a list of channels
	// (GET /v1/chatty/channels)
	PublicGetChannels(ctx echo.Context) error
	// Creates a new channel
	// (POST /v1/chatty/channels)
	PublicPostChannels(ctx echo.Context) error
	// Subscribe to a channel
	// (POST /v1/chatty/channels/{id}/subscribe)
	PublicPostChannelsSubscribe(ctx echo.Context, id string) error
	// Registers a new user
	// (POST /v1/chatty/signup)
	PublicPostSignup(ctx echo.Context) error
	// Returns a token
	// (POST /v1/chatty/token)
	PublicPostToken(ctx echo.Context) error
	// Returns a list of users
	// (GET /v1/chatty/users)
	PublicGetUsers(ctx echo.Context) error
	// Connects to Chatty to send and receive messages
	// (GET /v1/chatty/ws)
	PublicGetWs(ctx echo.Context) error
	// Returns a token for authentication with the Webscoket endpoint
	// (GET /v1/chatty/ws/token)
	PublicGetWsToken(ctx echo.Context) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) PublicGetChannels

func (w *ServerInterfaceWrapper) PublicGetChannels(ctx echo.Context) error

PublicGetChannels converts echo context to params.

func (*ServerInterfaceWrapper) PublicGetUsers

func (w *ServerInterfaceWrapper) PublicGetUsers(ctx echo.Context) error

PublicGetUsers converts echo context to params.

func (*ServerInterfaceWrapper) PublicGetWs

func (w *ServerInterfaceWrapper) PublicGetWs(ctx echo.Context) error

PublicGetWs converts echo context to params.

func (*ServerInterfaceWrapper) PublicGetWsToken

func (w *ServerInterfaceWrapper) PublicGetWsToken(ctx echo.Context) error

PublicGetWsToken converts echo context to params.

func (*ServerInterfaceWrapper) PublicPostChannels

func (w *ServerInterfaceWrapper) PublicPostChannels(ctx echo.Context) error

PublicPostChannels converts echo context to params.

func (*ServerInterfaceWrapper) PublicPostChannelsSubscribe

func (w *ServerInterfaceWrapper) PublicPostChannelsSubscribe(ctx echo.Context) error

PublicPostChannelsSubscribe converts echo context to params.

func (*ServerInterfaceWrapper) PublicPostSignup

func (w *ServerInterfaceWrapper) PublicPostSignup(ctx echo.Context) error

PublicPostSignup converts echo context to params.

func (*ServerInterfaceWrapper) PublicPostToken

func (w *ServerInterfaceWrapper) PublicPostToken(ctx echo.Context) error

PublicPostToken converts echo context to params.

type SignUpRequest

type SignUpRequest = SignUpSchema

SignUpRequest defines model for SignUpRequest.

type SignUpSchema

type SignUpSchema = LoginSchema

SignUpSchema defines model for SignUpSchema.

type SuccessChannelCreation

type SuccessChannelCreation struct {
	Id      string `json:"id"`
	Name    string `json:"name"`
	OwnerId string `json:"ownerId"`
}

SuccessChannelCreation defines model for SuccessChannelCreation.

type SuccessChannelSubscription

type SuccessChannelSubscription struct {
	Name string `json:"name"`
	Ok   bool   `json:"ok"`
}

SuccessChannelSubscription defines model for SuccessChannelSubscription.

type SuccessGetChannels

type SuccessGetChannels struct {
	Channels []Channel `json:"channels"`
}

SuccessGetChannels defines model for SuccessGetChannels.

type SuccessGetUsers

type SuccessGetUsers struct {
	Users []User `json:"users"`
}

SuccessGetUsers defines model for SuccessGetUsers.

type SuccessLoginSchema

type SuccessLoginSchema struct {
	Token string `json:"token"`
}

SuccessLoginSchema defines model for SuccessLoginSchema.

type SuccessSignupSchema

type SuccessSignupSchema struct {
	Id       string `json:"id"`
	Ok       *bool  `json:"ok,omitempty"`
	Username string `json:"username"`
}

SuccessSignupSchema defines model for SuccessSignupSchema.

type SuccessWsConnectionSchema

type SuccessWsConnectionSchema struct {
	Ok        bool   `json:"ok"`
	Timestamp string `json:"timestamp"`
}

SuccessWsConnectionSchema defines model for SuccessWsConnectionSchema.

type SystemHTTPServerConfig

type SystemHTTPServerConfig struct {
	Address string `json:"address"`
}

SystemHTTPServerConfig provides configuration for the system HTTP server

type UnauthorizedSchema

type UnauthorizedSchema struct {
	Message string `json:"message"`
}

UnauthorizedSchema defines model for UnauthorizedSchema.

type User

type User struct {
	Id       string `json:"id"`
	Username string `json:"username"`
}

User defines model for User.

type WebHandler

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

func NewWebHandler

func NewWebHandler(service ChattyService) *WebHandler

func (*WebHandler) PublicGetChannels

func (wh *WebHandler) PublicGetChannels(ctx echo.Context) error

func (*WebHandler) PublicGetUsers

func (wh *WebHandler) PublicGetUsers(ctx echo.Context) error

func (*WebHandler) PublicGetWs

func (wh *WebHandler) PublicGetWs(ctx echo.Context) error

func (*WebHandler) PublicGetWsToken

func (wh *WebHandler) PublicGetWsToken(ctx echo.Context) error

func (*WebHandler) PublicPostChannels

func (wh *WebHandler) PublicPostChannels(ctx echo.Context) error

func (*WebHandler) PublicPostChannelsSubscribe

func (wh *WebHandler) PublicPostChannelsSubscribe(ctx echo.Context, id string) error

func (*WebHandler) PublicPostSignup

func (wh *WebHandler) PublicPostSignup(ctx echo.Context) error

func (*WebHandler) PublicPostToken

func (wh *WebHandler) PublicPostToken(ctx echo.Context) error

Jump to

Keyboard shortcuts

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