Skip to content

Commit 9199fcd

Browse files
committed
add technical features section and remove the example page, 1.0.4 release
1 parent 1d43c7b commit 9199fcd

File tree

2 files changed

+13
-93
lines changed

2 files changed

+13
-93
lines changed

README.md

Lines changed: 13 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ _Last updated on October 17, 2018._ Click [here](_benchmarks/README.md) to read
6363
- __small api:__ with only 3 main methods for HTTP there's not much to learn
6464
- __compatibility:__ built to be 100% compatible with the `net/http` standard package
6565

66+
## Technical Features
67+
68+
- [x] Closest Wildcard Resolution and Root wildcard (CWR)[*](_examples/3_root_wildcard_and_custom-404/main.go)
69+
- [x] Parameterized Dynamic Path (named parameters with `:name` and wildcards with `*name`, can play all together for the same path prefix|suffix)[*](_examples/2_parameterized/main.go)
70+
- [x] Standard handlers chain (`Pre(handlers).For(mainHandler)` for individual routes and `Mux#Use` for router)[*](_examples/6_middleware/main.go)
71+
- [x] Register handlers by method(s) (`muxie.Methods()`)[*](_examples/7_by_methods/main.go)
72+
- [x] Register handlers by filters (`Mux#HandleRequest` and `Mux#AddRequestHandler` for `muxie.Matcher` and `muxie.RequestHandler`)
73+
- [x] Handle subdomains with ease (`muxie.Host` Matcher)[*](_examples/9_subdomains_and_matchers)
74+
- [x] Request Processors (`muxie.Bind` and `muxie.Dispatch`)[*](_examples/8_bind_req_send_resp)
75+
76+
Interested? Want to learn more about this library? Check out our tiny [examples](_examples) and the simple [godocs page](https://godoc.org/github.com/kataras/muxie).
77+
6678
## Installation
6779

6880
The only requirement is the [Go Programming Language](https://golang.org/dl/)
@@ -71,99 +83,6 @@ The only requirement is the [Go Programming Language](https://golang.org/dl/)
7183
$ go get -u github.com/kataras/muxie
7284
```
7385

74-
## Example
75-
76-
```go
77-
package main
78-
79-
import (
80-
"fmt"
81-
"net/http"
82-
83-
"github.com/rs/cors"
84-
85-
"github.com/kataras/muxie"
86-
)
87-
88-
func main() {
89-
mux := muxie.NewMux()
90-
mux.PathCorrection = true
91-
92-
// _examples/6_middleware
93-
mux.Use(cors.Default().Handler)
94-
95-
mux.HandleFunc("/", indexHandler)
96-
// Root wildcards, can be used for site-level custom not founds(404).
97-
mux.HandleFunc("/*path", notFoundHandler)
98-
99-
// Grouping.
100-
profile := mux.Of("/profile")
101-
profile.HandleFunc("/:name", profileHandler)
102-
profile.HandleFunc("/:name/photos", profilePhotosHandler)
103-
// Wildcards can be used for prefix-level custom not found handler as well,
104-
// order does not matter.
105-
profile.HandleFunc("/*path", profileNotFoundHandler)
106-
107-
// Dynamic paths with named parameters and wildcards or all together!
108-
mux.HandleFunc("/uploads/*file", listUploadsHandler)
109-
110-
mux.HandleFunc("/uploads/:uploader", func(w http.ResponseWriter, r *http.Request) {
111-
uploader := muxie.GetParam(w, "uploader")
112-
fmt.Fprintf(w, "Hello Uploader: '%s'", uploader)
113-
})
114-
115-
mux.HandleFunc("/uploads/info/*file", func(w http.ResponseWriter, r *http.Request) {
116-
file := muxie.GetParam(w, "file")
117-
fmt.Fprintf(w, "File info of: '%s'", file)
118-
})
119-
120-
mux.HandleFunc("/uploads/totalsize", func(w http.ResponseWriter, r *http.Request) {
121-
fmt.Fprint(w, "Uploads total size is 4048")
122-
})
123-
124-
fmt.Println("Server started at :8080")
125-
http.ListenAndServe(":8080", mux)
126-
}
127-
128-
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
129-
requestPath := muxie.GetParam(w, "path")
130-
// or r.URL.Path, we are in the root so it doesn't really matter.
131-
132-
fmt.Fprintf(w, "Global Site Page of: '%s' not found", requestPath)
133-
}
134-
135-
func profileNotFoundHandler(w http.ResponseWriter, r *http.Request) {
136-
requestSubPath := muxie.GetParam(w, "path")
137-
// requestSubPath = everyhing else after "http://localhost:8080/profile/..."
138-
// but not /profile/:name or /profile/:name/photos because those will
139-
// be handled by the above route handlers we registered previously.
140-
141-
fmt.Fprintf(w, "Profile Page of: '%s' not found", requestSubPath)
142-
}
143-
144-
func indexHandler(w http.ResponseWriter, r *http.Request) {
145-
w.Header().Set("Content-Type", "text/html;charset=utf8")
146-
fmt.Fprintf(w, "This is the <strong>%s</strong>", "index page")
147-
}
148-
149-
func profileHandler(w http.ResponseWriter, r *http.Request) {
150-
name := muxie.GetParam(w, "name")
151-
fmt.Fprintf(w, "Profile of: '%s'", name)
152-
}
153-
154-
func profilePhotosHandler(w http.ResponseWriter, r *http.Request) {
155-
name := muxie.GetParam(w, "name")
156-
fmt.Fprintf(w, "Photos of: '%s'", name)
157-
}
158-
159-
func listUploadsHandler(w http.ResponseWriter, r *http.Request) {
160-
file := muxie.GetParam(w, "file")
161-
fmt.Fprintf(w, "Showing file: '%s'", file)
162-
}
163-
164-
```
165-
Want to see more examples and documentation? Check out the [examples](_examples).
166-
16786
## Philosophy
16887

16988
I believe that providing the right tools for the right job represents my best self
@@ -200,4 +119,5 @@ Yours,<br />
200119
Gerasimos Maropoulos ([@MakisMaropoulos](https://twitter.com/MakisMaropoulos))
201120

202121
## License
122+
203123
[MIT](https://tldrlegal.com/license/mit-license)

0 commit comments

Comments
 (0)