From 55f707eb223811aee8483b449a86622495f9f138 Mon Sep 17 00:00:00 2001 From: hybris Date: Mon, 22 Oct 2018 17:01:08 +0200 Subject: [PATCH] initial commit --- LICENSE.md | 29 +++++++++++++++++++++++++++++ Makefile | 25 +++++++++++++++++++++++++ README.md | 38 ++++++++++++++++++++++++++++++++++++++ main.go | 19 +++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 LICENSE.md create mode 100644 Makefile create mode 100644 README.md create mode 100644 main.go diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..bcda400 --- /dev/null +++ b/LICENSE.md @@ -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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..491502f --- /dev/null +++ b/Makefile @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..4339aff --- /dev/null +++ b/README.md @@ -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 diff --git a/main.go b/main.go new file mode 100644 index 0000000..e85b46b --- /dev/null +++ b/main.go @@ -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) +}