zen

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: UPL-1.0 Imports: 2 Imported by: 0

README

zen-router

a simple wrapper around Go net/http.ServeMux

usage

// SPDX-License-Identifier: CC0
package main

import (
	"fmt"
	"codeberg.org/tilmanmixyz/go-zen"
	"net/http"
    "github.com/go-chi/chi/v5/middleware"
)

func main() {
    r := zen.NewRouter()
    // Subrouter Middleware works
    r.Use(middleware.Logger)
    r.Get("/lol", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "lol")
    })

    v1 := zen.NewRouter()
    v1.Mount("/v1", r)
    v1.Use(middleware.Logger)
    http.ListenAndServe(":8080", v1)
}

All files are licensed under the Universal Permissive License v1.0

Copyright (C) 2024 Tilman Andre Mix

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) Connect

func (r *Router) Connect(pattern string, handler http.HandlerFunc)

func (*Router) Delete

func (r *Router) Delete(pattern string, handler http.HandlerFunc)

func (*Router) Get

func (r *Router) Get(pattern string, handler http.HandlerFunc)

func (*Router) Handle

func (r *Router) Handle(pattern string, handler http.Handler)

func (*Router) HandleFunc

func (r *Router) HandleFunc(pattern string, handler http.HandlerFunc)

func (*Router) Head

func (r *Router) Head(pattern string, handler http.HandlerFunc)

func (*Router) Mount

func (r *Router) Mount(pattern string, handler http.Handler)

func (*Router) Options

func (r *Router) Options(pattern string, handler http.HandlerFunc)

func (*Router) Patch

func (r *Router) Patch(pattern string, handler http.HandlerFunc)

func (*Router) Post

func (r *Router) Post(pattern string, handler http.HandlerFunc)

func (*Router) Put

func (r *Router) Put(pattern string, handler http.HandlerFunc)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) Trace

func (r *Router) Trace(pattern string, handler http.HandlerFunc)

func (*Router) Use

func (r *Router) Use(middlewares ...func(http.Handler) http.Handler)

Jump to

Keyboard shortcuts

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