jiny

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

*------------------------------------------------------------**

  • @filename jiny/client.go
  • @author jinycoo
  • @version 1.0.0
  • @date 2019-09-19 10:00
  • @desc jiny - api client **------------------------------------------------------------*

*------------------------------------------------------------**

  • @filename jiny/csrf.go
  • @author jinycoo
  • @version 1.0.0
  • @date 2019-07-24 10:11
  • @desc jiny - csrf header validate **------------------------------------------------------------*

*------------------------------------------------------------**

  • @filename jiny/jiny.go
  • @author jinycoo
  • @version 1.0.0
  • @date 2019-07-24 09:41
  • @desc jiny - http server **------------------------------------------------------------*

*------------------------------------------------------------**

  • @filename auth/jwt.go
  • @author jinycoo
  • @version 1.0.0
  • @date 2019-07-24 14:15
  • @desc auth - jwt token **------------------------------------------------------------*

*------------------------------------------------------------**

  • @filename jiny/metadata.go
  • @author jinycoo
  • @version 1.0.0
  • @date 2019-09-19 10:14
  • @desc jiny - metadata **------------------------------------------------------------*

*------------------------------------------------------------**

  • @filename jiny/trace.go
  • @author jinycoo
  • @version 1.0.0
  • @date 2019-09-19 10:09
  • @desc jiny - trace **------------------------------------------------------------*

Index

Constants

View Source
const (
	Authorization = "Authorization"
	UCKey         = "78abffcf33c17bf9f3aef9be2a17284e6d2a1909"
	UCID          = "97d1474d94350970168b6ccb02bda90a585b69d0"
	SigningKey    = "aa9f16c7e942d86bd0738cb7cf61924a"
)

Variables

This section is empty.

Functions

func AccessToken

func AccessToken(acc *AccInfo, redura *ctime.Duration) (string, error)

func AuthJwtGroup

func AuthJwtGroup(relativePath string) *server.RouterGroup

func CSRF

func CSRF() server.HandlerFn

func Group

func Group(relativePath string, handlers ...server.HandlerFn) *server.RouterGroup

Group creates a new router group. You should add all the routes that have common middlewares or the same path prefix. For example, all the routes that use a common middleware for authorization could be grouped.

func Index

func Index(handler server.HandlerFn)

func Init

func Init(cfg *Config)

func JwtAuth

func JwtAuth() server.HandlerFn

func Ping

func Ping(handler server.HandlerFn)

Ping is used to set the general HTTP ping handler.

func PromMonitor

func PromMonitor()

func Routes

func Routes() server.RoutesInfo

Routes returns a slice of registered routes.

func Run

func Run() (err error)

func SignValid

func SignValid() server.HandlerFn

func SignValid1

func SignValid1(c *server.Context)

功能:获取所有请求过来的参数 author: haima time:2021.01.28

Types

type AccInfo

type AccInfo struct {
	ID       int64
	Email    string
	MID      int64
	Username string
	LoginAt  time.Time
	Issuer   string
}

type App

type App struct {
	Key    string
	Secret string
}

App jinycoo intranet authorization.

type Claims

type Claims struct {
	ID       int64  `json:"id"`
	MID      int64  `json:"mid"`
	Username string `json:"username"`
	jwt.StandardClaims
}

type Client

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

Client is http client.

func NewClient

func NewClient(c *ClientConfig) *Client

NewClient new a http client.

func (*Client) Do

func (client *Client) Do(c context.Context, req *http.Request, res interface{}, v ...string) (err error)

Do sends an HTTP request and returns an HTTP json response.

func (*Client) Get

func (client *Client) Get(c context.Context, uri, ip string, params url.Values, res interface{}) (err error)

Get issues a GET to the specified URL.

func (*Client) JSON

func (client *Client) JSON(c context.Context, req *http.Request, res interface{}, v ...string) (err error)

JSON sends an HTTP request and returns an HTTP json response.

func (*Client) NewRequest

func (client *Client) NewRequest(method, uri, realIP string, params url.Values) (req *http.Request, err error)

NewRequest new http request with method, uri, ip, values and headers.

func (*Client) PB

func (client *Client) PB(c context.Context, req *http.Request, res proto.Message, v ...string) (err error)

PB sends an HTTP request and returns an HTTP proto response.

func (*Client) Post

func (client *Client) Post(c context.Context, uri, ip string, params url.Values, res interface{}) (err error)

Post issues a Post to the specified URL.

func (*Client) RESTfulGet

func (client *Client) RESTfulGet(c context.Context, uri, ip string, params url.Values, res interface{}, v ...interface{}) (err error)

RESTfulGet issues a RESTful GET to the specified URL.

func (*Client) RESTfulPost

func (client *Client) RESTfulPost(c context.Context, uri, ip string, params url.Values, res interface{}, v ...interface{}) (err error)

RESTfulPost issues a RESTful Post to the specified URL.

func (*Client) Raw

func (client *Client) Raw(c context.Context, req *http.Request, v ...string) (bs []byte, err error)

Raw sends an HTTP request and returns bytes response

func (*Client) SetConfig

func (client *Client) SetConfig(c *ClientConfig)

SetConfig set client config.

func (*Client) SetTransport

func (client *Client) SetTransport(t http.RoundTripper)

SetTransport set client transport

type ClientConfig

type ClientConfig struct {
	*App
	Dial      ctime.Duration
	Timeout   ctime.Duration
	KeepAlive ctime.Duration
	Breaker   *breaker.Config
	URL       map[string]*ClientConfig
	Host      map[string]*ClientConfig
}

ClientConfig is http client conf.

type Config

type Config struct {
	Port          string
	AllowHosts    []string
	AllowPatterns []string
	SignPaths     []string
	Headers       map[string]string

	Prefix     string
	SigningKey string
	SignActive bool
	Sign       *Sign
	Expiry     ctime.Duration
	ReExpiry   ctime.Duration
	CasServer  string
}

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT() (j *JWT)

func (*JWT) Gen

func (j *JWT) Gen(claims Claims) (string, error)

func (*JWT) Parse

func (j *JWT) Parse(c *server.Context) (*Claims, error)

func (*JWT) Refresh

func (j *JWT) Refresh(tokenStr string) (string, error)

type Sign

type Sign struct {
	AppID   string
	PubKeys []string
}

type TraceTransport

type TraceTransport struct {

	// The actual RoundTripper to use for the request. A nil
	// RoundTripper defaults to http.DefaultTransport.
	http.RoundTripper
	// contains filtered or unexported fields
}

TraceTransport wraps a RoundTripper. If a request is being traced with Tracer, Transport will inject the current span into the headers, and set HTTP related tags on the span.

func NewTraceTracesport

func NewTraceTracesport(rt http.RoundTripper, peerService string, internalTags ...trace.Tag) *TraceTransport

NewTraceTracesport NewTraceTracesport

func (*TraceTransport) RoundTrip

func (t *TraceTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface

Directories

Path Synopsis
*------------------------------------------------------------** * @filename debug/pprof.go * @author jinycoo * @version 1.0.0 * @date 2019-07-25 13:10 * @desc debug - pprof 性能优化 **------------------------------------------------------------*
*------------------------------------------------------------** * @filename debug/pprof.go * @author jinycoo * @version 1.0.0 * @date 2019-07-25 13:10 * @desc debug - pprof 性能优化 **------------------------------------------------------------*
*------------------------------------------------------------** * @filename jiny/context.go * @author jinycoo * @version 1.0.0 * @date 2019-07-25 09:56 * @desc jiny - context **------------------------------------------------------------* *------------------------------------------------------------** * @filename jiny/params.go * @author jinycoo * @version 1.0.0 * @date 2019-08-01 13:58 * @desc jiny - params **------------------------------------------------------------* *------------------------------------------------------------** * @filename jiny/jiny.go * @author jinycoo * @version 1.0.0 * @date 2019-07-23 10:47 * @desc jiny - entry framework **------------------------------------------------------------*
*------------------------------------------------------------** * @filename jiny/context.go * @author jinycoo * @version 1.0.0 * @date 2019-07-25 09:56 * @desc jiny - context **------------------------------------------------------------* *------------------------------------------------------------** * @filename jiny/params.go * @author jinycoo * @version 1.0.0 * @date 2019-08-01 13:58 * @desc jiny - params **------------------------------------------------------------* *------------------------------------------------------------** * @filename jiny/jiny.go * @author jinycoo * @version 1.0.0 * @date 2019-07-23 10:47 * @desc jiny - entry framework **------------------------------------------------------------*

Jump to

Keyboard shortcuts

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