Help us shape the future of Go! Take the 2026 Go Developer Survey

jffs

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: GPL-3.0 Imports: 2 Imported by: 2

README

jffs

golang GoDoc Go Report Issues Size Tag License

Purpose

Often you don't want remote users to access your filesystem's static files outside the URLs you provide with your web-application. Especially if there are file(s) in your (sub-)directories which shouldn't be served to others. Therefor it's imperative to hamper the Go fileserver insofar as to not produce directory listings showing all available files. That's were this small package comes in.

Credits go to Brad Fitzpatrick.

Installation

You can use Go to install this package for you:

go get -u github.com/mwat56/jffs

Usage

This package exports a single function FileServer(). So, while you're used to call

myStaticDirectory :="/tmp"
myStaticHandler := http.FileServer(http.Dir(myStaticDirectory)))

to use this implementation you'd now just use:

myStaticHandler := jffs.FileServer(http.Dir(myStaticDirectory)))

That's all; just replace http by jffs.

Licence

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

You should have received a copy of the GNU General Public License along with this program. If not, see the GNU General Public License for details.

Documentation

Overview

Package jffs implements a handler that serves HTTP requests with the contents of the file system rooted at `aRoot` but without a complete directory listing.

Copyright © 2019 M.Watermann, 10247 Berlin, Germany
                All rights reserved
            EMail : <support@mwat.de>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

You should have received a copy of the GNU General Public License along with this program. If not, see the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileServer

func FileServer(aRoot http.FileSystem) http.Handler

FileServer returns a handler that serves HTTP requests with the contents of the file system rooted at `aRoot`.

To use the operating system's file system implementation, use `http.Dir()“:

myHandler := http.FileServer(http.Dir("/tmp")))

To use this implementation you'd use:

myHandler := jffs.FileServer(http.Dir("/tmp")))

`aRoot` The root of the filesystem to serve.

Types

This section is empty.

Jump to

Keyboard shortcuts

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