MethodBlock

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 2 Imported by: 0

README

HTTP Request Method Block

config example

# Static configuration

experimental:
  plugins:
    methodBlock:
        moduleName: github.com/moonlightwatch/MethodBlock
        version: v0.1.4

# Dynamic configuration

http:
  routers:
    my-router:
      rule: host(`demo.localhost`)
      service: service-foo
      entryPoints:
        - web
      middlewares:
        - my-plugin

  services:
   service-foo:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:5000
  
  middlewares:
    my-plugin:
      plugin:
        methodBlock:
          Message: "Method Not Allowed"
          Methods:
            - GET
            - POST

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error)

Types

type Config

type Config struct {
	Methods []string `json:"Methods,omitempty" toml:"Methods,omitempty" yaml:"Methods,omitempty" export:"true"`
	Message string   `json:"Message,omitempty" toml:"Message,omitempty" yaml:"Message,omitempty" export:"true"`
}

func CreateConfig

func CreateConfig() *Config

CreateConfig creates the default plugin configuration.

type MethodBlock

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

func (*MethodBlock) ServeHTTP

func (m *MethodBlock) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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