Documentation
¶
Overview ¶
Package httpadapter provides support for handling resource calls using an http.Handler.
Example ¶
handler := New(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
_, err := rw.Write([]byte("Hello world!"))
if err != nil {
return
}
rw.WriteHeader(http.StatusOK)
}))
_ = backend.ServeOpts{
CallResourceHandler: handler,
}
Example (Serve_mux) ¶
mux := http.NewServeMux()
mux.HandleFunc("/hello", func(rw http.ResponseWriter, _ *http.Request) {
_, err := rw.Write([]byte("Hello world!"))
if err != nil {
return
}
rw.WriteHeader(http.StatusOK)
})
handler := New(mux)
_ = backend.ServeOpts{
CallResourceHandler: handler,
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(handler http.Handler) backend.CallResourceHandler
New creates a new backend.CallResourceHandler adapter for handling resource calls using an http.Handler
func PluginConfigFromContext
deprecated
func PluginConfigFromContext(ctx context.Context) backend.PluginContext
PluginConfigFromContext returns backend.PluginConfig from context.
Deprecated: PluginConfigFromContext exists for historical compatibility and might be removed in a future version. Please migrate to backend.PluginConfigFromContext.
func UserFromContext
deprecated
UserFromContext returns backend.User from context.
Deprecated: UserFromContext exists for historical compatibility and might be removed in a future version. Please migrate to backend.UserFromContext.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.