server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

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

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.0.0 DO NOT EDIT.

Index

Constants

View Source
const JWTAuthHeader = "Authorization"

Variables

This section is empty.

Functions

func CorsMiddleware

func CorsMiddleware() gin.HandlerFunc

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 Healthcheck

func Healthcheck(ctx context.Context, conn *nats.Conn, store *Store, heartbeatTimoutSec int64, logger common.ServerLogrus)

func LoggingMiddleware

func LoggingMiddleware(logger common.ServerLogrus) gin.HandlerFunc

func NewHttpServer

func NewHttpServer(specpipeServer *SpecpipeServer, logger common.ServerLogrus, port string) *http.Server

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 gin.IRouter, si ServerInterface)

RegisterHandlers creates http.Handler with routing matching OpenAPI spec.

func RegisterHandlersWithOptions

func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)

RegisterHandlersWithOptions creates http.Handler with additional options

Types

type Config

type Config struct {
	Controller *ControllerConfig `mapstructure:"controller"`
	Health     *HealthConfig     `mapstructure:"health"`
}

type ControllerConfig added in v0.0.3

type ControllerConfig struct {
	Http    *HttpConfig    `mapstructure:"http"`
	Nats    *NatsConfig    `mapstructure:"nats"`
	Logging *LoggingConfig `mapstructure:"logging"`
}

func NewControllerConfig added in v0.0.3

func NewControllerConfig() (*ControllerConfig, error)

type ErrorResponse

type ErrorResponse struct {
	Detail string `json:"detail"`
	Title  string `json:"title"`
}

ErrorResponse defines model for error_response.

type FmDevice

type FmDevice struct {
	Freq            string  `json:"freq"`
	Latitude        float32 `json:"latitude"`
	Longitude       float32 `json:"longitude"`
	Name            string  `json:"name"`
	RegisterTs      int64   `json:"register_ts"`
	ResampleRate    string  `json:"resample_rate"`
	SampleRate      string  `json:"sample_rate"`
	SpecpipeVersion string  `json:"specpipe_version"`
}

FmDevice defines model for fm_device.

type FmDeviceResponse

type FmDeviceResponse struct {
	Device FmDevice `json:"device"`
}

FmDeviceResponse defines model for fm_device_response.

type FmDevicesResponse

type FmDevicesResponse struct {
	Devices []FmDevice `json:"devices"`
}

FmDevicesResponse defines model for fm_devices_response.

type GinServerOptions

type GinServerOptions struct {
	BaseURL      string
	Middlewares  []MiddlewareFunc
	ErrorHandler func(*gin.Context, error, int)
}

GinServerOptions provides options for the Gin server.

type HealthConfig added in v0.0.3

type HealthConfig struct {
	TimeoutSec int64
	Nats       *NatsConfig    `mapstructure:"nats"`
	Logging    *LoggingConfig `mapstructure:"logging"`
}

func NewHealthConfig added in v0.0.3

func NewHealthConfig() (*HealthConfig, error)

type HttpConfig

type HttpConfig struct {
	ServerPort string
}

type IqDevice

type IqDevice struct {
	Forward         bool    `json:"forward"`
	Freq            string  `json:"freq"`
	Latitude        float32 `json:"latitude"`
	Longitude       float32 `json:"longitude"`
	Name            string  `json:"name"`
	RegisterTs      int64   `json:"register_ts"`
	SampleRate      string  `json:"sample_rate"`
	SpecpipeVersion string  `json:"specpipe_version"`
}

IqDevice defines model for iq_device.

type IqDeviceResponse

type IqDeviceResponse struct {
	Device IqDevice `json:"device"`
}

IqDeviceResponse defines model for iq_device_response.

type IqDevicesResponse

type IqDevicesResponse struct {
	Devices []IqDevice `json:"devices"`
}

IqDevicesResponse defines model for iq_devices_response.

type LoggingConfig

type LoggingConfig struct {
	Level string
}

type MiddlewareFunc

type MiddlewareFunc func(c *gin.Context)

type NatsConfig

type NatsConfig struct {
	Url string
}

type PutFmDevicesDevicenameJSONRequestBody

type PutFmDevicesDevicenameJSONRequestBody = UpdateFmDeviceRequest

PutFmDevicesDevicenameJSONRequestBody defines body for PutFmDevicesDevicename for application/json ContentType.

type PutIqDevicesDevicenameJSONRequestBody

type PutIqDevicesDevicenameJSONRequestBody = UpdateIqDeviceRequest

PutIqDevicesDevicenameJSONRequestBody defines body for PutIqDevicesDevicename for application/json ContentType.

type ServerInterface

type ServerInterface interface {
	// List FM devices
	// (GET /fm/devices)
	GetFmDevices(c *gin.Context)
	// Read FM device configuration
	// (GET /fm/devices/{devicename})
	GetFmDevicesDevicename(c *gin.Context, devicename string)
	// Update FM device
	// (PUT /fm/devices/{devicename})
	PutFmDevicesDevicename(c *gin.Context, devicename string)
	// List IQ devices
	// (GET /iq/devices)
	GetIqDevices(c *gin.Context)
	// Read IQ device configuration
	// (GET /iq/devices/{devicename})
	GetIqDevicesDevicename(c *gin.Context, devicename string)
	// Update IQ device
	// (PUT /iq/devices/{devicename})
	PutIqDevicesDevicename(c *gin.Context, devicename string)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandler       func(*gin.Context, error, int)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) GetFmDevices

func (siw *ServerInterfaceWrapper) GetFmDevices(c *gin.Context)

GetFmDevices operation middleware

func (*ServerInterfaceWrapper) GetFmDevicesDevicename

func (siw *ServerInterfaceWrapper) GetFmDevicesDevicename(c *gin.Context)

GetFmDevicesDevicename operation middleware

func (*ServerInterfaceWrapper) GetIqDevices

func (siw *ServerInterfaceWrapper) GetIqDevices(c *gin.Context)

GetIqDevices operation middleware

func (*ServerInterfaceWrapper) GetIqDevicesDevicename

func (siw *ServerInterfaceWrapper) GetIqDevicesDevicename(c *gin.Context)

GetIqDevicesDevicename operation middleware

func (*ServerInterfaceWrapper) PutFmDevicesDevicename

func (siw *ServerInterfaceWrapper) PutFmDevicesDevicename(c *gin.Context)

PutFmDevicesDevicename operation middleware

func (*ServerInterfaceWrapper) PutIqDevicesDevicename

func (siw *ServerInterfaceWrapper) PutIqDevicesDevicename(c *gin.Context)

PutIqDevicesDevicename operation middleware

type SpecpipeServer

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

func NewSpecpipeServer

func NewSpecpipeServer(store *Store) *SpecpipeServer

func (*SpecpipeServer) GetFmDevices

func (s *SpecpipeServer) GetFmDevices(c *gin.Context)

func (*SpecpipeServer) GetFmDevicesDevicename

func (s *SpecpipeServer) GetFmDevicesDevicename(c *gin.Context, deviceName string)

func (*SpecpipeServer) GetIqDevices

func (s *SpecpipeServer) GetIqDevices(c *gin.Context)

func (*SpecpipeServer) GetIqDevicesDevicename

func (s *SpecpipeServer) GetIqDevicesDevicename(c *gin.Context, deviceName string)

func (*SpecpipeServer) PutFmDevicesDevicename

func (s *SpecpipeServer) PutFmDevicesDevicename(c *gin.Context, deviceName string)

func (*SpecpipeServer) PutIqDevicesDevicename

func (s *SpecpipeServer) PutIqDevicesDevicename(c *gin.Context, deviceName string)

type Store

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

func NewStore

func NewStore(conn *nats.Conn, kv jetstream.KeyValue) *Store

func (*Store) DeleteDevice

func (s *Store) DeleteDevice(ctx context.Context, sdrType common.SDRType, deviceName string) error

func (*Store) GetDevice

func (s *Store) GetDevice(ctx context.Context, sdrType common.SDRType, deviceName string) (bool, common.Device, error)

func (*Store) GetDevices

func (s *Store) GetDevices(ctx context.Context, sdrType common.SDRType) ([]common.Device, error)

func (*Store) UpdateDevice

func (s *Store) UpdateDevice(ctx context.Context, sdrType common.SDRType, deviceName string, deviceInfo common.Device) error

type UpdateFmDeviceRequest

type UpdateFmDeviceRequest struct {
	Freq         string  `json:"freq"`
	ResampleRate *string `json:"resample_rate,omitempty"`
	SampleRate   *string `json:"sample_rate,omitempty"`
}

UpdateFmDeviceRequest defines model for update_fm_device_request.

type UpdateIqDeviceRequest

type UpdateIqDeviceRequest struct {
	Freq       string  `json:"freq"`
	SampleRate *string `json:"sample_rate,omitempty"`
}

UpdateIqDeviceRequest defines model for update_iq_device_request.

Jump to

Keyboard shortcuts

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