Documentation ¶
Index ¶
- type App
- func (a *App) AddHTTPService(serviceName, serviceAddress string, options ...service.Options)
- func (a *App) DELETE(pattern string, handler Handler)
- func (a *App) GET(pattern string, handler Handler)
- 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)
- type Context
- type ErrCommandNotFound
- type Handler
- type Request
- type Responder
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) 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".
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 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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
redis
Package redis is a generated GoMock package.
|
Package redis is a generated GoMock package. |
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
|
|