Documentation ¶
Index ¶
- type App
- func (a *App) AddHTTPService(serviceName, serviceAddress string, options ...service.Options)
- func (a *App) AddRESTHandlers(object interface{}) error
- func (a *App) DELETE(pattern string, handler Handler)
- func (a *App) EnableAPIKeyAuth(apiKeys ...string)
- func (a *App) EnableAPIKeyAuthWithFunc(validator func(apiKey string) bool)
- func (a *App) EnableBasicAuth(credentials ...string)
- func (a *App) EnableBasicAuthWithFunc(validateFunc func(username, password string) bool)
- func (a *App) EnableOAuth(jwksEndpoint string, refreshInterval int)
- func (a *App) GET(pattern string, handler Handler)
- func (a *App) Logger() logging.Logger
- func (a *App) Metrics() metrics.Manager
- func (a *App) Migrate(migrationsMap map[int64]migration.Migrate)
- func (a *App) POST(pattern string, handler Handler)
- func (a *App) PUT(pattern string, handler Handler)
- func (a *App) RegisterService(desc *grpc.ServiceDesc, impl interface{})
- func (a *App) Run()
- func (a *App) SubCommand(pattern string, handler Handler)
- func (a *App) Subscribe(topic string, handler SubscribeFunc)
- func (a *App) UseMongo(db datasource.Mongo)
- type CRUD
- type Context
- type Create
- type Delete
- type ErrCommandNotFound
- type Exporter
- type Get
- type GetAll
- type Handler
- type Request
- type Responder
- type Span
- type SubscribeFunc
- type SubscriptionManager
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { // Config can be used by applications to fetch custom configurations from environment or file. Config config.Config // If we directly embed, unnecessary confusion between app.Get and app.GET will happen. // contains filtered or unexported fields }
App is the main application in the gofr framework.
func (*App) AddHTTPService ¶
AddHTTPService registers HTTP service in container.
func (*App) AddRESTHandlers ¶ added in v1.3.0
func (*App) EnableAPIKeyAuth ¶ added in v1.1.1
func (*App) EnableAPIKeyAuthWithFunc ¶ added in v1.1.1
func (*App) EnableBasicAuth ¶ added in v1.1.1
func (*App) EnableBasicAuthWithFunc ¶ added in v1.1.1
func (*App) EnableOAuth ¶ added in v1.1.1
func (*App) RegisterService ¶
func (a *App) RegisterService(desc *grpc.ServiceDesc, impl interface{})
RegisterService adds a grpc service to the gofr application.
func (*App) Run ¶
func (a *App) Run()
Run starts the application. If it is a HTTP server, it will start the server.
func (*App) SubCommand ¶
SubCommand adds a sub-command to the CLI application. Can be used to create commands like "kubectl get" or "kubectl get ingress".
func (*App) Subscribe ¶ added in v1.1.1
func (a *App) Subscribe(topic string, handler SubscribeFunc)
func (*App) UseMongo ¶ added in v1.3.0
func (a *App) UseMongo(db datasource.Mongo)
type Context ¶
type Context struct { context.Context // Request needs to be public because handlers need to access request details. Else, we need to provide all // functionalities of the Request as a method on context. This is not needed because Request here is an interface // So, internals are not exposed anyway. Request // Same logic as above. *container.Container // contains filtered or unexported fields }
func (*Context) Trace ¶
Trace returns an open telemetry span. We have to always close the span after corresponding work is done. Usages:
span := c.Trace("Some Work") // Do some work here. defer span.End()
If an entire function has to traced as span, we can use a simpler format:
defer c.Trace("ExampleHandler").End()
We can write this at the start of function and because of how defer works, trace will start at that line but End will be called after function ends.
Developer Note: If you chain methods in a defer statement, everything except the last function will be evaluated at call time.
type ErrCommandNotFound ¶
type ErrCommandNotFound struct{}
func (ErrCommandNotFound) Error ¶
func (e ErrCommandNotFound) Error() string
type Exporter ¶ added in v1.4.0
type Exporter struct {
// contains filtered or unexported fields
}
Exporter is responsible for exporting spans to a remote endpoint.
func NewExporter ¶ added in v1.4.0
NewExporter creates a new Exporter instance with a custom endpoint and logger.
func (*Exporter) ExportSpans ¶ added in v1.4.0
ExportSpans exports spans to the configured remote endpoint.
type Request ¶
type Request interface { Context() context.Context Param(string) string PathParam(string) string Bind(interface{}) error HostName() string }
Request is an interface which is written because it allows us to create applications without being aware of the transport. In both cmd or server application, this abstraction can be used.
type Responder ¶
type Responder interface {
Respond(data interface{}, err error)
}
Responder is used by the application to provide output. This is implemented for both cmd and http server application.
type Span ¶ added in v1.4.0
type Span struct { TraceID string `json:"traceId"` // Trace ID of the span. ID string `json:"id"` // ID of the span. ParentID string `json:"parentId,omitempty"` // Parent ID of the span. Name string `json:"name"` // Name of the span. Timestamp int64 `json:"timestamp"` // Timestamp of the span. Duration int64 `json:"duration"` // Duration of the span. Tags map[string]string `json:"tags,omitempty"` // Tags associated with the span. LocalEndpoint map[string]string `json:"localEndpoint"` // Local endpoint of the span. }
Span represents a span that will be exported.
type SubscribeFunc ¶ added in v1.1.1
type SubscriptionManager ¶ added in v1.1.1
type SubscriptionManager struct {
// contains filtered or unexported fields
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package container is a generated GoMock package.
|
Package container is a generated GoMock package. |
pubsub
Package pubsub provides a foundation for implementing pub/sub clients for various message brokers such as google pub-sub, kafka and MQTT.
|
Package pubsub provides a foundation for implementing pub/sub clients for various message brokers such as google pub-sub, kafka and MQTT. |
pubsub/google
Package google provides a client for interacting with Google Cloud Pub/Sub.This package facilitates interaction with Google Cloud Pub/Sub, allowing publishing and subscribing to topics, managing subscriptions, and handling messages.
|
Package google provides a client for interacting with Google Cloud Pub/Sub.This package facilitates interaction with Google Cloud Pub/Sub, allowing publishing and subscribing to topics, managing subscriptions, and handling messages. |
pubsub/kafka
Package kafka provides a client for interacting with Apache Kafka message queues.This package facilitates interaction with Apache Kafka, allowing publishing and subscribing to topics, managing consumer groups, and handling messages.
|
Package kafka provides a client for interacting with Apache Kafka message queues.This package facilitates interaction with Apache Kafka, allowing publishing and subscribing to topics, managing consumer groups, and handling messages. |
pubsub/mqtt
Package mqtt provides a client for interacting with MQTT message brokers.This package facilitates interaction with MQTT brokers, allowing publishing and subscribing to topics, managing subscriptions, and handling messages.
|
Package mqtt provides a client for interacting with MQTT message brokers.This package facilitates interaction with MQTT brokers, allowing publishing and subscribing to topics, managing subscriptions, and handling messages. |
redis
Package redis provides a client for interacting with Redis key-value stores.This package allows creating and managing Redis clients, executing Redis commands, and handling connections to Redis databases.
|
Package redis provides a client for interacting with Redis key-value stores.This package allows creating and managing Redis clients, executing Redis commands, and handling connections to Redis databases. |
sql
Package sql provides functionalities to interact with SQL databases using the database/sql package.This package includes a wrapper around sql.DB and sql.Tx to provide additional features such as query logging, metrics recording, and error handling.
|
Package sql provides functionalities to interact with SQL databases using the database/sql package.This package includes a wrapper around sql.DB and sql.Tx to provide additional features such as query logging, metrics recording, and error handling. |
cassandra
Module
|
|
clickhouse
Module
|
|
dgraph
Module
|
|
file/ftp
Module
|
|
file/s3
Module
|
|
file/sftp
Module
|
|
kv-store/badger
Module
|
|
mongo
Module
|
|
pubsub/eventhub
Module
|
|
pubsub/nats
Module
|
|
solr
Module
|
|
Package http provides a set of utilities for handling HTTP requests and responses within the GoFr framework.
|
Package http provides a set of utilities for handling HTTP requests and responses within the GoFr framework. |
middleware
Package middleware provides a collection of middleware functions that handles various aspects of request handling, such as authentication, logging, tracing, and metrics collection.
|
Package middleware provides a collection of middleware functions that handles various aspects of request handling, such as authentication, logging, tracing, and metrics collection. |
Package logging provides logging functionalities for Gofr applications.
|
Package logging provides logging functionalities for Gofr applications. |
Package metrics provides functionalities for instrumenting Gofr applications with metrics.
|
Package metrics provides functionalities for instrumenting Gofr applications with metrics. |
Package migration is a generated GoMock package.
|
Package migration is a generated GoMock package. |
Package service provides an HTTP client with features for logging, metrics, and resilience.It supports various functionalities like health checks, circuit-breaker and various authentication.
|
Package service provides an HTTP client with features for logging, metrics, and resilience.It supports various functionalities like health checks, circuit-breaker and various authentication. |