fn icon indicating copy to clipboard operation
fn copied to clipboard

Support for more custom request parsers

Open zeromake opened this issue 4 years ago • 0 comments

Here is my implementation

package main

import (
	"context"
	"net/http"
	"net/url"

	"github.com/pingcap/fn"
)
func main() {
	// Use reflection out(0) resp injection new request parser
	fn.SetRequestPlugin(func(ctx context.Context, r *http.Request) (url.Values, error) {
		return r.URL.Query(), nil
	})
	server := &http.Server{
		Addr:    ":8080",
		Handler: fn.Wrap(func (query url.Values) (string, error) {
			return query.Get("params"), nil
		}),
	}
	server.ListenAndServe()
}

zeromake avatar Mar 07 '20 13:03 zeromake