route

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package route and its subpackages provides most of what you need for http server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateDocs

func GenerateDocs(r Router) string

GenerateDocs json docs string for the router

Types

type Router

type Router struct {
	chi.Router
}

Router embeds chi router

func FilesServer

func FilesServer(stripPrefix string, dir string) Router

FilesServer gives you a (sub)router that serves only files from a directory (it hides your direcory structure) - accessing a (sub)directory will lead to index.html or StatusNotFound

A full path to served dir is required.

If mounted as a subrouter under certain path XY, specify stripPrefix equal to the mounting path XY.

Here is an example usage:

router := route.New()
...
workDir, _ := os.Getwd()
dir := filepath.Join(workDir, "relative_path_to_dir")
router.Mount("/static", route.FileServer("/static", dir))

func New

func New() Router

New returns new instance of router

Directories

Path Synopsis
Package ctx contains setters and getters for request context.
Package ctx contains setters and getters for request context.
Package middleware contains middlewares for logging, auth, custom errors and so on.
Package middleware contains middlewares for logging, auth, custom errors and so on.

Jump to

Keyboard shortcuts

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