Shareed2k / echo-static

Static middleware for echo web framework(golang)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Static middleware for echo web framework(golang)

License:MIT License


Languages

Language:Go 100.0%