http

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFieldsQuery = errors.New("Invalid fields query")

Functions

func AddPaginationToContext

func AddPaginationToContext(ctx *gin.Context) context.Context

AddPaginationToContext adds the pagination parameters to the context

func ParseQueryFields

func ParseQueryFields(q string, allowed []string, locked []string) ([]string, map[string]bool, error)

ParseQueryFields parses the query fields and returns a fields and an alias map Use fieldsMap to check if a field is present in the query

func WithTimeout

func WithTimeout(timeout time.Duration) func(options *Options)

Types

type AuthError

type AuthError struct {
	Error Error `json:"error"`
}

swagger:model authError

type CORS

type CORS struct {
	// IsEnabled is the flag to enable/disable CORS
	IsEnabled bool `yaml:"enabled" json:"enabled,omitempty" mapstructure:"enabled"`

	// AllowedOrigins is the list of allowed origins
	AllowedOrigins []string `yaml:"allowedOrigins" json:"allowedOrigins,omitempty" mapstructure:"allowedOrigins"`
}

Cross Origin Resource Sharing configuration

type Configuration

type Configuration struct {
	// Address is the address of the HTTP server
	Address string `yaml:"address" json:"address" mapstructure:"address"`

	// PathPrefix is the prefix for the endpoints
	PathPrefix string `yaml:"pathPrefix" json:"pathPrefix" mapstructure:"pathPrefix"`

	// TLS is the TLS configuration for the HTTP server
	TLS TLS `mapstructure:"tls" yaml:"tls" json:"tls"`
}

Http configuration for the API with TLS settings

type EmptyResponse

type EmptyResponse struct{}

swagger:model emptyResponse

type Error

type Error struct {
	Code    int    `json:"code"`
	Status  string `json:"status"`
	Message string `json:"message"`
}

type ErrorPayload

type ErrorPayload struct {
	Error       string `json:"error" mapstructure:"error"`
	Code        int    `json:"code" mapstructure:"code"`
	Description string `json:"description" mapstructure:"description"`
}

swagger:model errorResponse

type Options

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

type Server

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

func NewServer

func NewServer(config Configuration, obs observability.Observability, optionFuncs ...func(*Options)) *Server

func (*Server) Router

func (s *Server) Router() *gin.Engine

func (*Server) Run

func (s *Server) Run(checks ...checks.Check)

Run starts the HTTP server with the given healthchecks.

func (*Server) Shutdown added in v0.1.1

func (s *Server) Shutdown()

Shutdown stops the HTTP server gracefully

type TLS

type TLS struct {
	// IsEnabled is the flag to enable/disable TLS
	IsEnabled bool `yaml:"enabled" json:"enabled,omitempty" mapstructure:"enabled"`

	// RootCertificatePath is the path to the root certificate
	RootCertificatePath string `yaml:"rootCaPath" json:"rootCaPath,omitempty" mapstructure:"rootCaPath"`

	// CertificatePath is the path to the certificate
	CertificatePath string `yaml:"certPath" json:"certPath,omitempty" mapstructure:"certPath"`

	// PrivateKeyPath is the path to the private key
	PrivateKeyPath string `yaml:"keyPath" json:"keyPath,omitempty" mapstructure:"keyPath"`
}

TLS configuration with the option to enable/disable and with paths to the certificates

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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