httpadapter

package
v0.0.0-...-d8ecb06 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package httpadapter provides support for handling resource calls using an http.Handler.

Example
handler := New(http.HandlerFunc(func(rw http.ResponseWriter, req *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, req *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

func PluginConfigFromContext(ctx context.Context) backend.PluginContext

PluginConfigFromContext returns backend.PluginConfig from context.

func UserFromContext

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

UserFromContext returns backend.User from context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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