Added simple gopherd cmd (server) and Dockerfile (image)
This commit is contained in:
parent
48590e76b1
commit
91ba32dc29
|
@ -0,0 +1,18 @@
|
|||
FROM golang:alpine
|
||||
|
||||
EXPOSE 70/tcp
|
||||
|
||||
ENTRYPOINT ["gopherd"]
|
||||
CMD []
|
||||
|
||||
RUN \
|
||||
apk add --update git && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
RUN mkdir -p /go/src/github.com/prologic/gopherproxy
|
||||
WORKDIR /go/src/github.com/prologic/go-gopher
|
||||
|
||||
COPY . /go/src/github.com/prologic/go-gopher
|
||||
|
||||
RUN go get -v -d
|
||||
RUN go install -v github.com/prologic/go-gopher/...
|
|
@ -9,7 +9,7 @@ server handling and examples of each.
|
|||
## Installation
|
||||
|
||||
```#!bash
|
||||
$ go get github.com/prologic/go-gopher
|
||||
$ go get github.com/prologic/go-gopher/...
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
@ -18,6 +18,11 @@ $ go get github.com/prologic/go-gopher
|
|||
import "github.com/prologic/go-gopher"
|
||||
```
|
||||
|
||||
Or run the builtin (*very simple*) server:
|
||||
```#!bash
|
||||
$ gopherd
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
### Client
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/prologic/go-gopher"
|
||||
)
|
||||
|
||||
func cwd() string {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
func main() {
|
||||
var (
|
||||
bind = flag.String("bind", ":70", "port to listen on")
|
||||
root = flag.String("root", cwd(), "root directory to serve")
|
||||
)
|
||||
|
||||
flag.Parse()
|
||||
|
||||
gopher.Handle("/", gopher.FileServer(gopher.Dir(*root)))
|
||||
|
||||
log.Fatal(gopher.ListenAndServe(*bind, nil))
|
||||
}
|
Loading…
Reference in New Issue