static

package module
Version: v0.0.0-...-aa7c038 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2017 License: MIT Imports: 4 Imported by: 7

README

echo-static

Build Status Coverage Status Go Report Card GoDoc MIT License

SYNOPSIS

package main

import (
    static "github.com/Code-Hex/echo-static"
 
    assetfs "github.com/elazarl/go-bindata-assetfs"
    "github.com/labstack/echo"
)

func main() {
    e := echo.New()

    e.Use(static.ServeRoot("/static", NewAssets("assets")))
    e.GET("/ping", func(c echo.Context) error {
        return c.String(200, "test")
    })
    // Listen and Server in 0.0.0.0:8080
    e.Start(":8080")
}

func NewAssets(root string) *assetfs.AssetFS {
	return &assetfs.AssetFS{
		Asset:     Asset,
		AssetDir:  AssetDir,
		AssetInfo: AssetInfo,
		Prefix:    root,
	}
}

and put your asset file in the assets directory and execute the following code before compile it.

go-bindata -o bindata.go assets/...

DESCRIPTION

echo-static is File server middleware for go-bindata and echo.

INSTALLATION

go get github.com/Code-Hex/echo-static

AUTHOR

codehex

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryFileSystem

func BinaryFileSystem(fs *assetfs.AssetFS) *binaryFileSystem

func Serve

func Serve(urlPrefix string, fs ServeFileSystem) echo.MiddlewareFunc

Serve Static returns a middleware handler that serves static files in the given directory.

func ServeRoot

func ServeRoot(urlPrefix string, fs *assetfs.AssetFS) echo.MiddlewareFunc

Types

type ServeFileSystem

type ServeFileSystem interface {
	http.FileSystem
	Exists(prefix string, path string) bool
}

ServeFileSystem

Source Files

Jump to

Keyboard shortcuts

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