README
¶
Gateway
Package gateway is the main program for TCP and HTTP services.
Demo
package main
import (
"github.com/henrylee2cn/cfgo"
"github.com/xiaoenai/tp-micro/gateway"
)
func main() {
cfg := gateway.NewConfig()
cfgo.MustReg("gateway", cfg)
// Run a gateway instance with default business logic and default socket protocol.
gateway.Run(*cfg, nil, nil)
}
Usage
Authorization
-
HTTP short connection gateway
- Optional authorization
- Use query or header parameter to carry authorization token
-
TCP long connection gateway
- Required authorization
- Use the first packet of the connection to carry authorization information:
Package typeCALL
, URI/auth/verify
, BodyTypes
, Bodyaccess token string
RequestID
-
HTTP short connection gateway
- Optional query parameter
- Use query parameter
_seq
to carry request ID
-
TCP long connection gateway
- Required packet
seq
field - The request ID is
{session ID}@{packet seq}
- Required packet
HTTP Status Code
- 200 OK
- 299 Business error
- 500 Internal communication error
- Other codes (200,600)
Documentation
¶
Overview ¶
Package gateway is the main program for TCP and HTTP services.
Copyright 2018 github.com/xiaoenai. All Rights Reserved.
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.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HostsNamespace ¶
func HostsNamespace() string
HostsNamespace returns the gateway hosts prefix of ETCD key.
func RegBodyCodecForHTTP ¶ added in v1.1.0
RegBodyCodecForHTTP registers a mapping of content type to body coder (for http).
func Run ¶
Run the gateway main program. If protoFunc=nil, rawproto.NewRawProtoFunc is used by default. If biz=nil, types.DefaultBusiness() is used by default.
func SetHostsNamespace ¶
func SetHostsNamespace(prefix string)
SetHostsNamespace sets the gateway hosts prefix of ETCD key.
Types ¶
type Config ¶
type Config struct { EnableHttp bool `yaml:"enable_http"` EnableSocket bool `yaml:"enable_socket"` EnableWebSocket bool `yaml:"enable_web_socket"` OuterHttpServer short.HttpSrvConfig `yaml:"outer_http_server"` OuterSocketServer micro.SrvConfig `yaml:"outer_socket_server"` InnerSocketServer micro.SrvConfig `yaml:"inner_socket_server"` InnerSocketClient micro.CliConfig `yaml:"inner_socket_client"` WebSocketServer micro.SrvConfig `yaml:"web_socket_server"` Etcd etcd.EasyConfig `yaml:"etcd"` }
Config app config
Directories
¶
Path | Synopsis |
---|---|
helper
|
|
agent/proto
Package agent is a generated protocol buffer package.
|
Package agent is a generated protocol buffer package. |
gray/logic/model
Package model is a generated protocol buffer package.
|
Package model is a generated protocol buffer package. |
gray/types
Package types is a generated protocol buffer package.
|
Package types is a generated protocol buffer package. |
Package types is a generated protocol buffer package.
|
Package types is a generated protocol buffer package. |