Skip to content

💭 Slid is a static file server with routing support.

License

Notifications You must be signed in to change notification settings

molnarmark/slid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slid

Open Source Love Open Source Love PRs Welcome

Slid is a static file server with routing.

Example

package main

import (
	"fmt"

	"github.com/molnarmark/slid"
)

func main() {
	config := &slid.Config{
		Port: 9898,
		Dir:  "files",
	}

	// Makes a new slid instance with the config
	app := slid.New(config)

	// Adding a route with a path and a specific handler function.
	app.Get("/", func(c *slid.Context) {
		c.Text("Homepage, with plain text sent.")
	})

	// You can also call the Serve method on the context to send back a file.
	app.Get("/anotherindex", func(c *slid.Context) {
		c.Serve("index")
	})

	// A quick way is also available to map a route to a filename
	app.GetFile("/index", "index")

	app.Run(func() {
		fmt.Println("Slid is running.")
	})
}

Releases

No releases published

Packages

No packages published

Languages