apputils

package
v0.0.0-...-816697b Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Index

Constants

View Source
const (
	RPROXY_LOG_REQUEST_HEADERS  = 1 << 0
	RPROXY_LOG_RESPONSE_HEADERS = 1 << 1
	RPROXY_LOG_ERROR            = 1 << 2
	RPROXY_LOG_SUCCESS          = 1 << 3
	RPROXY_LOG_PROXY_REQUEST    = 1 << 5
	RPROXY_LOG_PROXY_HEADERS    = 1 << 6
	RPROXY_DISABLE_REDIRECT     = 1 << 7
)
View Source
const (
	DEBUG = false
)

Variables

View Source
var ErrKeepaliveTimeout = errors.New("Keepalive timeout")
View Source
var ErrRedirect = errors.New("redirect foiled")

Functions

func CopyHeader

func CopyHeader(dst http.Header, src http.Header, key string)

func DefaultVersionHostname

func DefaultVersionHostname(r *http.Request) string

func Error

func Error(w http.ResponseWriter, r *http.Request, code int, msg string, logErr error)

func GAEBackendInstance

func GAEBackendInstance() (string, error)

func HttpJsonRpc

func HttpJsonRpc(r *http.Request, u *url.URL, method string, rpoptions uint64, request interface{}, reply interface{}) error

* This method and the supporting RProxy() function are purpose built for App Engine, * And more specifically for Appengine apps that want to either * talk between modules in the same app, or talk between apps.

func InternalServerError

func InternalServerError(w http.ResponseWriter, r *http.Request, msg string, logErr error)

* TODO(tadhunt): replace hacky wrapper around open source http logging library to correctly * log appengine errors with something better

func Log

func Log(r *http.Request, msg string)

func LogHeaders

func LogHeaders(ctx context.Context, msg string, headers http.Header)

func LogRequestHeaders

func LogRequestHeaders(r *http.Request, msg string)

func ProjectID

func ProjectID() (string, error)

func RProxy

func RProxy(r *http.Request, cfg *RProxyConfig, method string, u *url.URL, data []byte) ([]byte, error)

func RProxyOptions

func RProxyOptions(str string) uint64

func ServiceAccounts

func ServiceAccounts() ([]string, error)

Types

type AuthToken

type AuthToken struct {
	Type   string `json:"token_type"`
	Token  string `json:"access_token"`
	Expiry uint   `json:"expires_in"`
}

func GetAuthToken

func GetAuthToken(account string) (*AuthToken, error)
type Header struct {
	Key   string
	Value string
}

type KeepAlive

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

func NewKeepAlive

func NewKeepAlive(r *http.Request, topic string, timeout time.Duration) (*KeepAlive, error)

func (*KeepAlive) Pull

func (keepalive *KeepAlive) Pull(msgHandler func(msg *KeepAliveMessage) error) error

Fetch and process (waiting if necessary) messages for up to the timeout given when the keepalive was created

type KeepAliveMessage

type KeepAliveMessage struct {
	Hostname string
	Instance string
	Seq      uint64
	URL      *url.URL
}

func ParseKeepAliveMessage

func ParseKeepAliveMessage(m *pubsub.Message) (*KeepAliveMessage, error)

func (*KeepAliveMessage) String

func (m *KeepAliveMessage) String() string

type RProxyConfig

type RProxyConfig struct {
	Copy    []string
	Add     []*Header
	Options uint64
}

type ServiceAccount

type ServiceAccount struct {
	Aliases []string `json:"aliases"`
	Email   string   `json:"email"`
	Scopes  []string `json:"scopes"`
}

func GetServiceAccount

func GetServiceAccount(name string) (*ServiceAccount, error)

Jump to

Keyboard shortcuts

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