Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to main.go #4

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions gate.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package g8

import (
"net/http"
)
import "net/http"

const (
// AuthorizationHeader is the header in which g8 looks for the authorization bearer token
//yes, const is just declared here similar to a dsa body
// AuthorizationHeader = the header in which g8 looks for the authorization bearer token
AuthorizationHeader = "Authorization"

// DefaultUnauthorizedResponseBody is the default response body returned if a request was sent with a missing or
// DefaultUnauthorizedResponseBody = the default response body returned if a request was sent with a missing or
// invalid token
DefaultUnauthorizedResponseBody = "Authorization Bearer token is missing or invalid"
)

// Gate is lock to the front door of your API, letting only those you allow through.
// Gate = lock to the front door of your API, letting only those you allow through.
type Gate struct {
authorizationService *AuthorizationService
unauthorizedResponseBody []byte
Expand All @@ -27,13 +26,13 @@ func NewGate(authorizationService *AuthorizationService) *Gate {
}
}

// WithCustomUnauthorizedResponseBody sets a custom response body when Gate determines that a request must be blocked
// WithCustomUnauthorizedResponseBody = a custom response body when Gate determines that a request must be blocked
func (gate *Gate) WithCustomUnauthorizedResponseBody(unauthorizedResponseBody []byte) *Gate {
gate.unauthorizedResponseBody = unauthorizedResponseBody
return gate
}

// Protect secures a handler, requiring requests going through to have a valid Authorization Bearer token.
// Protect = secured handler, requiring requests going through to have a valid Authorization Bearer token.
// Unlike ProtectWithPermissions, Protect will allow access to any registered tokens, regardless of their permissions
// or lack thereof.
//
Expand Down