caddy_nrt

package module
v0.0.0-...-1a360c0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

Caddy Middleware Plugin

This is a experimental plugin for Caddy V2 that allow you to proxy HTTP requests to a NATS backed set of backends.

$ cat Caddyfile
{
    order nats last
}

http://:9090 {
        nats /* weather.nats 
}

Now any request to port 9090 will forward to the NATS hosted service cluster.

$ curl http://localhost:9090/city -d '{"city":"london"}' -v
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9090 (#0)
> POST /city HTTP/1.1
> Host: localhost:9090
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 17
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Mon, 17 May 2021 14:37:02 GMT
< Content-Length: 293
< Content-Type: text/plain; charset=utf-8
<
HTTP/1.1 200 OK
Content-Length: 104
Content-Type: text/plain; charset=utf-8
Nrt-Client: 4019
Nrt-Connected-Cluster: lon
Nrt-Connected-Server: n2-lon
Nrt-Id: VYOnC1jYhwUAR15DsIecFH

[
  {
    "id": 804,
    "main": "Clouds",
    "description": "overcast clouds",
    "icon": "04d"
  }
]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Nats

type Nats struct {
	Context string `json:"context"`
	Service string `json:"service"`
	// contains filtered or unexported fields
}

func (Nats) CaddyModule

func (n Nats) CaddyModule() caddy.ModuleInfo

func (*Nats) Provision

func (n *Nats) Provision(ctx caddy.Context) error

func (*Nats) ServeHTTP

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

func (*Nats) UnmarshalCaddyfile

func (n *Nats) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

func (*Nats) Validate

func (n *Nats) Validate() error

Jump to

Keyboard shortcuts

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