pluginlogger

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

本レポジトリは、traefikのミドルウェアプラグインを自作する(Go) のために作られたサンプル実装レポジトリです。 production環境でのユースを想定したプラグインではありません。ご容赦ください。

Build Status

Documentation

Overview

Package pluginlogger is a demo logger plugin.

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)

New プラグイン本体を作成する関数 CreateConfig() と同じく、Yaegiから直接呼び出されるので必須 また、関数シグネチャは`New(context.Context, http.Handler, *Config, string) (http.Handler, error)` である必要がある

Types

type Config

type Config struct {
	Prefix   string `json:"prefix,omitempty"`
	LogLevel string `json:"loglevel,omitempty"`
}

Config プラグインの設定が入った構造体 yaegiから設定情報が注入されるので、全フィールドをPublicにする

func CreateConfig

func CreateConfig() *Config

CreateConfig 設定を作成する関数 yaegiから呼び出されるため、必須

type Logger

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

Logger プラグインの本体。必要な依存性を内部に保持する http.Handler を実装する

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP はミドルウェアの実処理

Jump to

Keyboard shortcuts

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