initial commit
This commit is contained in:
commit
55f707eb22
29
LICENSE.md
Normal file
29
LICENSE.md
Normal file
@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2018, hybris
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
Makefile
Normal file
25
Makefile
Normal file
@ -0,0 +1,25 @@
|
||||
BINARY := serve
|
||||
|
||||
SOURCEDIR=.
|
||||
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
|
||||
|
||||
SRC_BIN :="${SOURCEDIR}/${BINARY}"
|
||||
DST_BIN :="/usr/local/bin/${BINARY}"
|
||||
|
||||
.DEFAULT_GOAL := $(BINARY)
|
||||
|
||||
$(BINARY): $(SOURCES)
|
||||
go get -t ./...
|
||||
go build ${LDFLAGS} -o ${BINARY}
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
scp ${SRC_BIN} ${DST_BIN}
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
if ! [ -f ${DST_BIN} ] ; then rm ${DST_BIN} ; fi
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
if [ -f ${BINARY} ] ; then rm ${BINARY} ; fi
|
38
README.md
Normal file
38
README.md
Normal file
@ -0,0 +1,38 @@
|
||||
# serve
|
||||
|
||||
simple golang wrapper around [http.Fileserver](https://golang.org/pkg/net/http/#FileServer) and [http.ServeFile](https://golang.org/pkg/net/http/#ServeFile)
|
||||
|
||||
## Installing
|
||||
|
||||
Installation is simple. Just run the following command:
|
||||
```
|
||||
$ go get github.com/oevermod/serve
|
||||
$ cd $GOPATH/src/github.com/oevermod/serve
|
||||
$ make && make install clean
|
||||
```
|
||||
|
||||
`make install` will copy `serve` to `/usr/local/bin/`
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ serve --help
|
||||
Usage of serve:
|
||||
-f string
|
||||
directory/file to be served
|
||||
-i string
|
||||
desired address (default all)
|
||||
-p int
|
||||
desired port (default 8080)
|
||||
```
|
||||
|
||||
## Uninstalling
|
||||
|
||||
To uninstall just run:
|
||||
```
|
||||
$ make uninstall
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the FreeBSD License - see the [LICENSE.md](LICENSE.md) file for details
|
19
main.go
Normal file
19
main.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2018 hybris. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/oevermod/serve-core"
|
||||
)
|
||||
|
||||
var path = flag.String("f", "", "directory/file to be served")
|
||||
var ip = flag.String("i", "", "desired ip address (default all)")
|
||||
var port = flag.Int("p", 8080, "desired port")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
serve.Serve(*path,*ip,*port)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user