KaguyaKernel

package module
Version: v0.0.0-...-c65aab8 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

Kaguya Kernel for XI

Version GoLang License

The opensource instant messaging framework, migrate into XI.

License

    Copyright 2021 Star Inc.(https://starinc.xyz)

    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.

Documentation

Overview

Package KaguyaKernel: The opensource instant messaging framework.

Copyright 2021 Star Inc.(https://starinc.xyz)
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

View Source
const (
	ErrorJSONDecodingRequest = "JSON_decoding_request_error"
	ErrorInvalidRequestType  = "Request_type_is_invalid"
)
View Source
const (
	ErrorJSONEncodingResponseData = "JSON_encoding_response_data_error"
	ErrorJSONEncodingResponse     = "JSON_encoding_response_error"
	ErrorGenerateSignature        = "Generate_signature_error"
	ErrorSessionClosed            = "Session_closed_error"
)
View Source
const ErrorForbidden = "Forbidden"

Variables

This section is empty.

Functions

func Run

func Run(service ServiceInterface, guard AuthorizeInterface, middlewares MiddlewareInterface, requestSalt string) *melody.Melody

Run: to execute KaguyaKernel with specific arguments.

Types

type AuthorizeInterface

type AuthorizeInterface interface {
	Me() string
	Permission(target string) bool
}

type ErrorReport

type ErrorReport struct {
	Error     string `json:"error"`
	Timestamp int64  `json:"timestamp"`
}

type MiddlewareInterface

type MiddlewareInterface interface {
	OnRequestBefore() []func(session *Session, request *Request)
	OnRequestAfter() []func(session *Session, request *Request)
	OnResponseBefore() []func(session *Session, data interface{})
	OnResponseAfter() []func(session *Session, response *Response)
}

MiddlewareInterface:

type Request

type Request struct {
	Data interface{} `json:"data"`
	Type string      `json:"type"`
}

type Response

type Response struct {
	Data      []byte `json:"data"`
	Signature string `json:"signature"`
	Timestamp int64  `json:"timestamp"`
}

type Service

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

func (*Service) CheckRequestType

func (service *Service) CheckRequestType(method reflect.Value) bool

func (*Service) GetGuard

func (service *Service) GetGuard() AuthorizeInterface

func (*Service) GetSession

func (service *Service) GetSession() *Session

func (*Service) SetGuard

func (service *Service) SetGuard(authorization AuthorizeInterface)

func (*Service) SetSession

func (service *Service) SetSession(session *Session)

type ServiceInterface

type ServiceInterface interface {
	Fetch(ctx context.Context)
	CheckPermission() bool
	GetGuard() AuthorizeInterface
	SetGuard(authorization AuthorizeInterface)
	GetSession() *Session
	SetSession(session *Session)
	CheckRequestType(method reflect.Value) bool
}

type Session

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

func NewSession

func NewSession(socketSession *melody.Session, middlewares MiddlewareInterface, requestSalt string) *Session

NewSession: starts a new session.

func (*Session) RaiseError

func (session *Session) RaiseError(message string)

RaiseError: throw an error to client.

func (*Session) Response

func (session *Session) Response(data interface{})

Response: response a data to client.

type Signature

type Signature struct {
	Data      []byte `json:"data"`
	Salt      string `json:"salt"`
	Timestamp int64  `json:"timestamp"`
}

Directories

Path Synopsis
service
box

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL