sitex

command module
v0.0.0-...-00970cc Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2017 License: MIT Imports: 14 Imported by: 0

README

SiteX

Go Report Card codecov Build Status

A HTTP server with support to Netlify's redirect and rewrite rules, custom headers, and basic auth.

Note: Since Netlify is a proprietary service. It's really hard to fully mimic Netlify's behavior. So most implementation here is based on guessing and intuition.

go get -u github.com/poga/sitex

Usage

Define the redirect rules with _redirects file.

# redirect / to test.json
/ /test.json 200

# 301 redirect
/foo /test.json

# query params
/bar id=:id /test-:id.json

# proxy
/google https://google.com 200

You can also define custom headers and/or basic authentication with _headers file.

# A path:
/test.json
  # Headers for that path:
  X-Frame-Options: DENY
  X-XSS-Protection: 1; mode=block

# basic auth
/something/*
  Basic-Auth: someuser:somepassword anotheruser:anotherpassword

Start SiteX server with sitex command.

$ sitex

Now you got a web server which:

  • http://localhost:8080/ will render /test.json
  • http://localhost:8080/test.json will render the file
  • http://localhost:8080/foo will redirect to /test.json
  • http://localhost:8080/bar?id=2 will render /test-2.json

CLI options

  • dir: the directory you want to server. Default: current working directory.
  • port: port to listen. Default: 8080.

Rules

Note: Custom header is a paid-only feature on Netlify.

See _headers and _redirects file in the example folder.

For detailed documents, see Netlify's redirect document and header document.

Contribute

Feel free to open an issue if you find difference between SiteX and Netlify.

License

The MIT License

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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