ws

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2016 License: BSD-3-Clause Imports: 5 Imported by: 0

README

ws

A nimble web server

ws is a prototyping platform for web based services and websites.

ws has a minimal feature set
  • A simple static file webserver
    • quick startup
    • activity logged to the console
    • supports http2 out of the box
  • A project setup option called init

Configuration

You can configure ws with command line options or environment variables. Try ws -help for a list of command line options.

Environment variables
  • WS_URL the URL to listen for by ws
  • WS_HTDOCS the directory of your static content you need to serve
    • the default is ./htdocs
  • WS_SSL_KEY the path the the SSL key file (e.g. etc/ssl/site.key)
    • default is empty, only checked if your WS_URL is starts with https://
  • WS_SSL_CERT the path the the SSL cert file (e.g. etc/ssl/site.crt)
    • default is empty, only checked if your WS_URL is starts with https://
Command line options
  • -url overrides WS_URL
  • -htdocs overrides WS_HTDOCS
  • -ssl-key overrides WS_SSL_KEY
  • -ssl-pem overrides WS_SSL_PEM
  • -init triggers the initialization process and creates a setup.bash file
  • -h, -help displays the help documentation
  • -v, -version display the version of the command
  • -l, -license displays license information

Running ws without environment variables or command line options is an easy way to server your current working directory's content out as http://localhost:8000.

Need to quickly build out a website from Markdown files or other JSON resources? Take a look at mkpage.

Installation

ws is available as precompile binaries for Linux, Mac OS X, and Windows 10 on Intel. Additional binaries are provided for Raspbian on ARM6 adn ARM7. Follow the INSTALL.md instructions to download and install the pre-compiled binaries.

If you have Golang installed then ws can be installed with the go get command.

    go get github.com/caltechlibrary/ws/...

Compiling from source

Required

  • Golang version 1.7 or better

Here's my basic approach to get things setup. Go 1.7 needs to be already installed.

  git clone https://github.com/caltechlibrary/ws
  cd ws
  go test
  go build
  go build cmds/ws/ws.go

If everything compiles fine then I do something like this--

  go install cmds/ws/ws.go

LICENSE

copyright (c) 2016 Caltech See LICENSE for details

Documentation

Overview

Package ws provides the core library used by cmds/ws/ws.go

@author R. S. Doiel, <rsdoiel@caltech.edu>

Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. 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.

3. 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.

Index

Constants

View Source
const (
	// Version is used as a release number number for ws, wsinit, wsindexer
	Version = "v0.0.10"

	// LicenseText holds the text and placeholders to render a license in the cli
	LicenseText = `` /* 1530-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func IsDotPath

func IsDotPath(p string) bool

IsDotPath checks to see if a path is requested with a dot file (e.g. docs/.git/* or docs/.htaccess)

func RequestLogger

func RequestLogger(next http.Handler) http.Handler

RequestLogger logs the request based on the request object passed into it.

func ResponseLogger

func ResponseLogger(r *http.Request, status int, err error)

ResponseLogger logs the response based on a request, status and error message

func StaticRouter

func StaticRouter(next http.Handler) http.Handler

StaticRouter scans the request object to either add a .html extension or prevent serving a dot file path

Types

This section is empty.

Directories

Path Synopsis
cmds
ws command
ws.go - A simple web server for static files and limit server side JavaScript @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.
ws.go - A simple web server for static files and limit server side JavaScript @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2016, Caltech All rights not granted herein are expressly reserved by Caltech Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.

Jump to

Keyboard shortcuts

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