Giter Site home page Giter Site logo

gowebhello's Introduction

license Go Report Card

gowebhello

gowebhello is a simple golang replacement for 'python -m SimpleHTTPServer'. gowebhello can also be configured as an HTTPS web server using SSL certificates.

Usage

HTTPS

If you want to use TLS, you will need a certificate:

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem

Building

Without Modules, before Go 1.11

# make sure GOPATH is either unset or properly set
go get github.com/udhos/gowebhello
go install github.com/udhos/gowebhello

With Modules, starting from Go 1.11

git clone https://github.com/udhos/gowebhello ;# clone outside of GOPATH
cd gowebhello
go install ./gowebhello

Running

Use the '-h' switch to get command line help.

$ gowebhello -h

Example with TLS

Enable TLS by providing a certificate. If you enable TLS, HTTP port will be redirected to HTTPS port.

$ ~/go/bin/gowebhello
2017/06/08 11:24:03 registering static directory /home/lab/go/src/github.com/udhos/gowebhello as www path /www/
2017/06/08 11:24:03 using TCP ports HTTP=:8080 HTTPS=:8443 TLS=true
2017/06/08 11:24:03 installing redirect from HTTP=:8080 to HTTPS=8443
2017/06/08 11:24:03 serving HTTPS on TCP :8443

Then open https://localhost:8443

Example without TLS

If you do not provide a certificate, TLS will be disabled.

$ ~/go/bin/gowebhello -cert=badcert
2017/06/08 11:25:01 TLS cert file not found: badcert - disabling TLS
2017/06/08 11:25:01 registering static directory /home/lab/go/src/github.com/udhos/gowebhello as www path /www/
2017/06/08 11:25:01 using TCP ports HTTP=:8080 HTTPS=:8443 TLS=false
2017/06/08 11:25:01 serving HTTP on TCP :8080

Then open http://localhost:8080

Example with HTTPS only

You can disable HTTP by specifying the same port to both -addr and -httpsAddr.

$ ~/go/bin/gowebhello -addr :8443 -httpsAddr :8443
2017/06/08 11:25:46 registering static directory /home/lab/go/src/github.com/udhos/gowebhello as www path /www/
2017/06/08 11:25:46 using TCP ports HTTP=:8443 HTTPS=:8443 TLS=true
2017/06/08 11:25:46 serving HTTPS on TCP :8443

Container image

Find a small container image for gowebhello as udhos/web-scratch here:

https://hub.docker.com/r/udhos/web-scratch

#END

gowebhello's People

Contributors

shantanugadgil avatar udhos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gowebhello's Issues

[feature request] disable HTTP; use HTTPS only

In the current cmd set, when I only use HTTPS (parameter -httpsAddr), the -addr parameter is assumed to be 8080.

This becomes a problem when I have to launch multiple HTTPS gowebhellos to simulate multiple HTTPS services on one machine.

For now,

  1. I have just added a large number (20000) to the HTTPS port and used that for HTTP port value. (to keep gowebhello happy), so that the HTTP ports are outside any real usable port range.
  2. Another solution I tried out was specifying ':0' as the -addr parameter; random port gets used.

Regards,
Shantanu

[feature request] show HTTP headers

Would it be possible to add a flag to dump the HTTP headers being sent by the client?

This would come in handy while testing what headers a third party proxy/AWS ALB/NGINX is sending.
Thanks and Regards,
Shantanu Gadgil

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.