envoy

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

Simplified Go interface for HTTP Golang Filter on Envoy Proxy

A simplified interface for building plugin on Envoy Proxy with HTTP Golang Filter.

Features

  • Porting net/http interface experience to extend Envoy Proxy behavior with HTTP Golang Filter.

Development Guide

Prerequisites
Setup
  • Install Git.

  • Install Go 1.20.

  • Clone the project.

    $ git clone -b plugin git@github.com:ardkabs/go-envoy.git
    
  • Create a meaningful branch

    $ git checkout -b <your-meaningful-branch>
    
  • Test your changes.

    $ make test
    
  • We highly recommend instead of only run test, please also do audit which include formatting, linting, vetting, and testing.

    $ make audit
    
  • Add, commit, and push changes to repository

    $ git add .
    $ git commit -s -m "<conventional commit style>"
    $ git push origin <your-meaningful-branch>
    

    For writing commit message, please use conventionalcommits as a reference.

  • Create a Pull Request (PR). In your PR's description, please explain the goal of the PR and its changes.

Testing
Unit Test
$ make test
Try It

To try this interface in action, heads to example directory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSimpleJSONBody

func CreateSimpleJSONBody(code, message string, errs ...error) []byte

func DefaultErrorHandler

func DefaultErrorHandler(ctx Context, err error) api.StatusType

func NewRequestHandler

func NewRequestHandler(ctx RequestContext) *requestHandler

func NewRequestHandlerWithErrorHandler

func NewRequestHandlerWithErrorHandler(ctx RequestContext, errHandler ErrorHandler) *requestHandler

func NewResponseHandler

func NewResponseHandler(ctx ResponseContext) *responseHandler

func NewResponseHandlerWithErrorHandler

func NewResponseHandlerWithErrorHandler(ctx ResponseContext, errHandler ErrorHandler) *responseHandler

func ToFlatHeader

func ToFlatHeader(header http.Header) map[string]string

Types

type Context

type Context interface {
	Header

	Log(lvl LogLevel, msg string)

	JSON(statusCode int, body []byte, headers map[string]string, opts ...LocalReplyOption) error

	PlainText(statusCode int, msg string, opts ...LocalReplyOption) error

	StatusType() api.StatusType
}

type ErrorHandler

type ErrorHandler func(Context, error) api.StatusType
type Header interface {
	api.HeaderMap
}

type LocalReplyOption

type LocalReplyOption func(o *LocalReplyOptions)

func WithGrpcStatus

func WithGrpcStatus(status int64) LocalReplyOption

func WithLocalReplyDetail

func WithLocalReplyDetail(detail string) LocalReplyOption

type LocalReplyOptions

type LocalReplyOptions struct {
	// contains filtered or unexported fields
}

func GetDefaultLocalReplyOptions

func GetDefaultLocalReplyOptions() *LocalReplyOptions

type LogLevel

type LogLevel api.LogType
const (
	DebugLevel LogLevel = iota + 1
	InfoLevel
	WarnLevel
	ErrorLevel
	CriticalLevel
)

type RequestContext

type RequestContext interface {
	Context

	Host() string

	Path() string

	Method() string
}

func NewRequestContext

func NewRequestContext(header api.RequestHeaderMap, callback api.FilterCallbacks) (RequestContext, error)

type RequestHandler

type RequestHandler func(next RequestHandlerFunc) RequestHandlerFunc

type RequestHandlerFunc

type RequestHandlerFunc func(ctx RequestContext, req *http.Request) error

type ResponseContext

type ResponseContext interface {
	Context

	Status() (int, bool)
}

func NewResponseContext

func NewResponseContext(header api.ResponseHeaderMap, callback api.FilterCallbacks) (ResponseContext, error)

type ResponseHandler

type ResponseHandler func(next ResponseHandlerFunc) ResponseHandlerFunc

type ResponseHandlerFunc

type ResponseHandlerFunc func(ctx ResponseContext, res *http.Response) error

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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