caddy_pirsch_plugin

package module
v0.0.0-...-3725872 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

Go Coding Time

caddy-pirsch-plugin

A Caddy v2 plugin to track requests in Pirsch Analytics.

Usage

pirsch [<matcher>] {
    client_id <pirsch-client-id>
    client_secret <pirsch-client-secret>
    base_url <alternative-api-url>
}

You can obtain these parameters from the Settings section of your Pirsch dashboard.

Because this directive does not come standard with Caddy, you need to put the directive in order. The correct place is up to you, but usually putting it near the end works if no other terminal directives match the same requests. It's common to pair a Pirsch handler with a file_server, so ordering it just before is often a good choice:

{
	order pirsch before file_server
}

Alternatively, you may use route to order it the way you want. For example:

localhost
root * /srv
route {
	pirsch * {
		[...]
	}
	file_server
}
Example

Track all requests to HTML pages in Pirsch. You might want to extend the matcher regexp to also include / or, alternatively, match everything but assets (like .css, .js, ...) since usually you wouldn't want to track those.

{
    order pirsch before file_server
}

http://localhost:8080 {
    @html path_regexp .*\.html$

    pirsch @html {
        client_id cCfoZttXzRH5AyOpiu97wqXH3j5lYXcg
        client_secret olshVxS73jWQFhXJE86DdoR4McPBh02OendvyLtajX2EA3aasfywb3q3uZio9tDL
    }

    file_server
}

License

Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PirschPlugin

type PirschPlugin struct {
	ClientId     string `json:"client_id,omitempty"`
	ClientSecret string `json:"client_secret,omitempty"`
	BaseURL      string `json:"base_url,omitempty"`
	// contains filtered or unexported fields
}

func (PirschPlugin) CaddyModule

func (m PirschPlugin) CaddyModule() caddy.ModuleInfo

func (*PirschPlugin) Provision

func (m *PirschPlugin) Provision(ctx caddy.Context) (err error)

func (*PirschPlugin) ServeHTTP

func (m *PirschPlugin) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

Jump to

Keyboard shortcuts

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