simplemux

package module
v0.0.0-...-1703703 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 1 Imported by: 0

README

simplemux

Usage

package main

import (
	"net/http"

	"github.com/Acebond/simplemux"
)

func testHandler(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("Hello World"))
}

func main() {
	mux := &simplemux.Mux{}
	mux.HandlerFunc(http.MethodGet, "/test", testHandler)
	http.ListenAndServe(":8080", mux)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mux

type Mux struct {
	NotFound http.Handler
	// contains filtered or unexported fields
}

func (*Mux) HandlerFunc

func (mux *Mux) HandlerFunc(method, path string, handler http.HandlerFunc)

func (*Mux) ServeHTTP

func (mux *Mux) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP makes the router implement the http.Handler interface.

type Route

type Route struct {
	Method  string
	Path    string
	Handler http.HandlerFunc
}

Jump to

Keyboard shortcuts

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