httpadapter

package
v0.260.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 8 Imported by: 45

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,
}
Output:

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,
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

func UserFromContext(ctx context.Context) *backend.User

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.

Jump to

Keyboard shortcuts

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