Skip to content

Commit

Permalink
hide examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Feb 14, 2019
1 parent a7c973d commit d4fb457
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example_helper_test.go → examples/example_helper_test.go
@@ -1,4 +1,4 @@
package semaphore_test
package examples_test

import (
"net/http"
Expand Down
@@ -1,4 +1,4 @@
package semaphore_test
package examples_test

import (
"fmt"
Expand Down
@@ -1,6 +1,6 @@
// +build go1.6

package semaphore_test
package examples_test

import (
"fmt"
Expand Down
@@ -1,4 +1,4 @@
package semaphore_test
package examples_test

import (
"fmt"
Expand Down
@@ -1,6 +1,6 @@
// +build go1.7

package semaphore_test
package examples_test

import (
"fmt"
Expand Down
@@ -1,6 +1,6 @@
// +build go1.7

package semaphore_test
package examples_test

import (
"context"
Expand Down Expand Up @@ -84,7 +84,7 @@ func RateLimiter(cnf Config, handler http.HandlerFunc) http.HandlerFunc {
// UserToContext gets user ID from request header and puts it into request context.
func UserToContext(cnf Config, handler http.HandlerFunc) http.HandlerFunc {
return func(rw http.ResponseWriter, req *http.Request) {
var user User = cnf.DefaultUser
var user = cnf.DefaultUser

if id := req.Header.Get("user"); id != "" {
i, err := strconv.Atoi(id)
Expand All @@ -99,7 +99,7 @@ func UserToContext(cnf Config, handler http.HandlerFunc) http.HandlerFunc {

// This example shows how to create user-specific rate limiter.
func Example_userRateLimitation() {
var cnf Config = Config{
var cnf = Config{
DefaultUser: 1,
DefaultCapacity: runtime.GOMAXPROCS(0),
DefaultRateLimit: 10 * time.Millisecond,
Expand Down

0 comments on commit d4fb457

Please sign in to comment.