package
0.0.8
Repository: https://github.com/lithdew/flatend.git
Documentation: pkg.go.dev

# README

file

Here's something trippy: a service that responds with its own source code.

$ flatend
2020/06/17 02:36:30 Listening for Flatend nodes on '127.0.0.1:9000'.
2020/06/17 02:36:30 Listening for HTTP requests on '[::]:3000'.
2020/06/17 02:36:41 <anon> has connected to you. Services: [file]

$ node index.js
Successfully dialed 127.0.0.1:9000. Services: []

$ http://localhost:3000/
const {Node} = require("flatend");
const fs = require("fs");

const main = async () => {
    const node = new Node();
    node.register('file', ctx => fs.createReadStream("index.js").pipe(ctx));
    await node.dial("127.0.0.1:9000");
}

main().catch(err => console.error(err));
addr = "127.0.0.1:9000"

[[http]]
addr = ":3000"

[[http.routes]]
path = "GET /"
service = "file"
const { Node } = require("flatend");
const fs = require("fs");

const main = async () => {
  const node = new Node();
  node.register("file", (ctx) => fs.createReadStream("index.js").pipe(ctx));
  await node.dial("127.0.0.1:9000");
};

main().catch((err) => console.error(err));