pipe

command
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 4 Imported by: 0

README

pipe

Whatever comes in must come out. Simple piping example: upload a file to POST /pipe.

$ flatend
2020/06/17 01:07:12 Listening for Flatend nodes on '127.0.0.1:9000'.
2020/06/17 01:07:12 Listening for HTTP requests on '[::]:3000'.
2020/06/17 01:07:17 <anon> has connected to you. Services: [pipe]

$ go run main.go
2020/06/17 01:07:17 You are now connected to 127.0.0.1:9000. Services: []

$ POST /pipe (1.6MiB GIF)
addr = "127.0.0.1:9000"

[[http]]
addr = ":3000"

[[http.routes]]
path = "POST /pipe"
service = "pipe"
package main

import (
	"github.com/lithdew/flatend"
	"io"
	"os"
	"os/signal"
)

func check(err error) {
	if err != nil {
		panic(err)
	}
}

func pipe(ctx *flatend.Context) {
	_, _ = io.Copy(ctx, ctx.Body)
}

func main() {
	node := &flatend.Node{
		Services: map[string]flatend.Handler{
			"pipe": pipe,
		},
	}
	check(node.Start("127.0.0.1:9000"))

	ch := make(chan os.Signal, 1)
	signal.Notify(ch, os.Interrupt)
	<-ch

	node.Shutdown()
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy