Skip to content

Commit

Permalink
Rename to webify
Browse files Browse the repository at this point in the history
beefsack committed Aug 28, 2020
1 parent b42f92d commit dbf73aa
Showing 7 changed files with 30 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.3.0] - 2020-08-27
### Changed
- Renamed project to webify.

## [1.2.0] - 2020-08-27
### Added
- Started CHANGELOG.md.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM golang:1.14

WORKDIR /go/src/script-httpd
WORKDIR /go/src/webify

COPY . .
RUN go get && go build

# By default, script-httpd listens on all interfaces on port 8080
# By default, webify listens on all interfaces on port 8080
EXPOSE 80
ENV ADDR :80

# By default, script-httpd executes /script
# By default, webify executes /script
ENV SCRIPT /script

CMD ["./script-httpd"]
CMD ["./webify"]
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# script-httpd
# webify

script-httpd is a simple tool to turn a command line script into a web service.
webify is a simple tool to turn a command line script into a web service.

<p align="center">
<img src="https://i.imgur.com/1wL9m5C.gif">
</p>

script-httpd is essentially a very basic CGI server which forwards all requests
webify is essentially a very basic CGI server which forwards all requests
to a single script. A design goal is to be as close to zero-config as possible.

script-httpd invokes your script and writes the request body to your process'
webify invokes your script and writes the request body to your process'
stdin. Stdout is then passed back to the client as the HTTP response body.

If your script returns a non-zero exit code, the HTTP response status code will
be 500.

## Installation

script-httpd is available from the [project's releases page](https://github.com/beefsack/script-httpd/releases).
webify is available from the [project's releases page](https://github.com/beefsack/webify/releases).

## Usage

```bash
# Make a web service out of `wc` to count the characters in the request body.
$ script-httpd wc -c
$ webify wc -c
2020/08/25 12:42:32 listening on :8080, proxying to wc -c

...
@@ -34,7 +34,7 @@ $ curl -d 'This is a really long sentence' http://localhost:8080

### Official Docker image

The official Docker image is [beefsack/script-httpd](https://hub.docker.com/r/beefsack/script-httpd).
The official Docker image is [beefsack/webify](https://hub.docker.com/r/beefsack/webify).

It can be configured using the following environment variables:

@@ -44,7 +44,7 @@ It can be configured using the following environment variables:
#### Mounting script and running official image

```
$ docker run -it --rm -p 8080:80 -v /path/to/my/script:/script beefsack/script-httpd:latest
$ docker run -it --rm -p 8080:80 -v /path/to/my/script:/script beefsack/webify:latest
2020/08/25 04:27:46 listening on :80, proxying to /script
...
@@ -57,7 +57,7 @@ $ curl -d 'Some data' http://localhost:8080
Create a `Dockerfile` like the following:

```
FROM beefsack/script-httpd:latest
FROM beefsack/webify:latest
COPY myscript /script
```

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/beefsack/script-httpd
module github.com/beefsack/webify

go 1.15

14 changes: 7 additions & 7 deletions scripthttpd/flag.go → lib/flag.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scripthttpd
package lib

import (
"fmt"
@@ -13,16 +13,16 @@ import (
const EnvScript = "SCRIPT"

const helpHeader = `
script-httpd is a simple helper to turn a command line script into an HTTP
webify is a simple helper to turn a command line script into an HTTP
service.
Homepage: http://github.com/beefsack/script-httpd
Homepage: http://github.com/beefsack/webify
script-httpd functions by starting the script for each request and piping the
webify functions by starting the script for each request and piping the
HTTP request body into stdin of the subprocess. stdout is captured and returned
as the body of the HTTP response.
stderr is not sent to the client, but is logged to the script-httpd process
stderr is not sent to the client, but is logged to the webify process
stderr. stderr can be sent to the client using redirection if required.
The exit status of the script determines the HTTP status code for the response:
@@ -31,11 +31,11 @@ isn't sent until the script completes.
Example server that responds with the number of lines in the request body:
script-httpd wc -l
webify wc -l
Piping and redirection are supported by calling a shell directly:
script-httpd bash -c 'date && wc -l'
webify bash -c 'date && wc -l'
All options are also exposed as environment variables, entirely in uppercase.
Eg. -addr can also be specified using the environment variable ADDR. The script
2 changes: 1 addition & 1 deletion scripthttpd/server.go → lib/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scripthttpd
package lib

import (
"io"
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package main

import (
"github.com/beefsack/webify/lib"

"log"
"net/http"
"strings"

"github.com/beefsack/script-httpd/scripthttpd"
)

func main() {
opts := scripthttpd.ParseConfig()
opts := lib.ParseConfig()

log.Printf("listening on %s, proxying to %s", opts.Addr, strings.Join(opts.Script, " "))
log.Fatal(http.ListenAndServe(opts.Addr, &scripthttpd.Server{Opts: opts}))
log.Fatal(http.ListenAndServe(opts.Addr, &lib.Server{Opts: opts}))
}

0 comments on commit dbf73aa

Please sign in to comment.