server

command
v0.0.0-...-4d4d6b9 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 4 Imported by: 0

README

Primitive for your Web Server

Add a route to your existing web server

The following will bind a new route to your server where users can POST files to /primitive with the file form key and process them with primitive. The response returns a raw PNG buffer with Content-Type image/png.

import (
	"net/http"

	pr "github.com/fogleman/primitive/server/route"
)

handler := pr.PrimitiveRoute(pr.Config{
	MaxUploadMb: 10,
	FileKey: "file",
})
http.HandleFunc("/primitive", handler)

Example web server

An examples web server you can start that has a /primitive route bound that accepts file uploads to be processed with primitive can be started with the following instructions.

$ go get github.com/fogleman/primitive/server

$ # run the web server on port :8080
$ go run $(go env GOPATH)/src/github.com/fogleman/primitive/server

$ # in another terminal window, make sure the server is running
$ curl localhost:8080
We're running!

TODOS

  • Make all parameters configurable (Background, Alpha, Mode, etc.)
  • Dockerfile for example web server

Documentation

Overview

main.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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