Documentation ¶
Index ¶
- func AddSpan(ctx context.Context, spanName string, keyValues ...attribute.KeyValue) (context.Context, trace.Span)
- func Decode(r *http.Request, val any) error
- func GetTime(ctx context.Context) time.Time
- func GetTraceID(ctx context.Context) string
- func IsShutdownError(err error) bool
- func NewShutdownError(message string) error
- func Param(r *http.Request, key string) string
- func Respond(ctx context.Context, w http.ResponseWriter, data any, statusCode int) error
- func SetStatusCode(ctx context.Context, statusCode int)
- func SetValues(ctx context.Context, v *Values) context.Context
- type App
- type Handler
- type MessageResponse
- type Middleware
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSpan ¶
func AddSpan(ctx context.Context, spanName string, keyValues ...attribute.KeyValue) (context.Context, trace.Span)
AddSpan adds a OpenTelemetry span to the trace and context.
func Decode ¶
Decode reads the body of an HTTP request looking for a JSON document. The body is decoded into the provided value. If the provided value is a struct then it is checked for validation tags. If the value implements a validate function, it is executed.
func GetTraceID ¶
GetTraceID returns the trace id from the context.
func IsShutdownError ¶
IsShutdownError checks to see if the shutdown error is contained in the specified error value.
func NewShutdownError ¶
NewShutdownError returns an error that causes the framework to signal a graceful shutdown.
func SetStatusCode ¶
SetStatusCode sets the status code back into the context.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the entrypoint of out application.
func NewApp ¶
func NewApp(shutdown chan os.Signal, tracer trace.Tracer, log *logger.Logger, mw ...Middleware) *App
NewApp creates new instance of our application.
func (*App) EnableCORS ¶
func (a *App) EnableCORS(mw Middleware)
EnableCORS enables CORS preflight requests to work in the middleware. It prevents the MethodNotAllowedHandler from being called. This must be enabled for the CORS middleware to work.
func (*App) ServeHTTP ¶
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface.
func (*App) SignalShutdown ¶
func (a *App) SignalShutdown()
SignalShutdown is used to gracefully shut down the app.
type MessageResponse ¶
type MessageResponse struct {
Msg string `json:"message"`
}
type Middleware ¶
Middleware is a function designed to run before and/or after some Handler.