Documentation ¶
Index ¶
- Constants
- Variables
- func DeserializeHttpRequestPattern(ctx *core.Context, it *jsoniter.Iterator, pattern core.Pattern, try bool) (_ core.Pattern, finalErr error)
- func GenerateSelfSignedCertAndKey(args SelfSignedCertParams) (cert *pem.Block, key *pem.Block, err error)
- func GetTLSConfig(ctx *core.Context, pemEncodedCert string, pemEncodedKey string) (*tls.Config, error)
- func HttpRead(ctx *core.Context, u core.URL, args ...core.Value) (result core.Value, finalErr error)
- func IsMutationMethod(method string) bool
- func MakeHTTPProxy(ctx *core.Context, params HTTPProxyParams) (*http.Server, error)
- func Mime_(ctx *core.Context, arg core.String) (core.Mimetype, error)
- func NewGolangHttpServer(ctx *core.Context, config GolangHttpServerConfig) (*http.Server, error)
- func NewHttpNamespace() *core.Namespace
- func PercentDecode(ctx *core.Context, s core.StringLike) (core.String, error)
- func PercentEncode(ctx *core.Context, s core.StringLike) core.String
- func ServeFile(ctx *core.Context, rw *ResponseWriter, r *Request, pth core.Path) error
- type API
- type ApiEndpoint
- type CSPDirective
- type CSPDirectiveValue
- type CSPHeaderValueParams
- type Client
- func (c *Client) DoRequest(ctx *core.Context, req *Request) (*Response, error)
- func (c *Client) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (c *Client) GetGoMethod(name string) (*core.GoFunction, bool)
- func (c *Client) GetHostCookieObjects(ctx *core.Context, h core.Host) *core.List
- func (c *Client) GetHostCookies(h core.Host) []*http.Cookie
- func (c *Client) IsMutable() bool
- func (c *Client) MakeRequest(ctx *core.Context, method string, u core.URL, body io.Reader, ...) (*Request, error)
- func (c *Client) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (c *Client) Prop(ctx *core.Context, name string) core.Value
- func (*Client) PropertyNames(ctx *core.Context) []string
- func (c *Client) Schemes() []core.Scheme
- func (*Client) SetProp(ctx *core.Context, name string, value core.Value) error
- func (c *Client) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- type ClientConfig
- type ContentSecurityPolicy
- func (c *ContentSecurityPolicy) Directive(directiveName string) (CSPDirective, bool)
- func (c *ContentSecurityPolicy) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (c *ContentSecurityPolicy) HeaderValue(params CSPHeaderValueParams) string
- func (*ContentSecurityPolicy) IsMutable() bool
- func (csp *ContentSecurityPolicy) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (csp *ContentSecurityPolicy) String() string
- func (*ContentSecurityPolicy) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (c *ContentSecurityPolicy) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, ...) error
- func (c *ContentSecurityPolicy) WriteRepresentation(ctx *core.Context, w io.Writer, config *core.ReprConfig, depth int) error
- type GolangHttpServerConfig
- type HTTPProxyParams
- type HttpsServer
- func (serv *HttpsServer) Close(ctx *core.Context)
- func (s *HttpsServer) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (serv *HttpsServer) GetGoMethod(name string) (*core.GoFunction, bool)
- func (serv *HttpsServer) ImmediatelyClose(ctx *core.Context)
- func (serv *HttpsServer) IsMutable() bool
- func (serv *HttpsServer) ListeningAddr() core.Host
- func (s *HttpsServer) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (s *HttpsServer) Prop(ctx *core.Context, name string) core.Value
- func (*HttpsServer) PropertyNames(ctx *core.Context) []string
- func (*HttpsServer) SetProp(ctx *core.Context, name string, value core.Value) error
- func (serv *HttpsServer) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (serv *HttpsServer) WaitClosed(ctx *core.Context)
- type IncomingRequestInfo
- type Request
- func (req *Request) AcceptAny() bool
- func (r *Request) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (req *Request) GetGoMethod(name string) (*core.GoFunction, bool)
- func (req *Request) IsGetOrHead() bool
- func (req *Request) IsMutable() bool
- func (req *Request) IsSharable(originState *core.GlobalState) (bool, string)
- func (req *Request) IsShared() bool
- func (r *Request) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (req *Request) Prop(ctx *core.Context, name string) core.Value
- func (*Request) PropertyNames(ctx *core.Context) []string
- func (req *Request) Request() *http.Request
- func (*Request) SetProp(ctx *core.Context, name string, value core.Value) error
- func (req *Request) Share(originState *core.GlobalState)
- func (req *Request) SmartLock(state *core.GlobalState)
- func (req *Request) SmartUnlock(state *core.GlobalState)
- func (req *Request) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (r *Request) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, ...) error
- func (r *Request) WriteRepresentation(ctx *core.Context, w io.Writer, config *core.ReprConfig, depth int) error
- type RequestOptions
- type RequestPattern
- func (p *RequestPattern) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (*RequestPattern) IsMutable() bool
- func (*RequestPattern) Iterator(*core.Context, core.IteratorConfiguration) core.Iterator
- func (p *RequestPattern) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (*RequestPattern) Random(ctx *core.Context, options ...core.Option) core.Value
- func (*RequestPattern) StringPattern() (core.StringPattern, bool)
- func (p *RequestPattern) Test(ctx *core.Context, v core.Value) bool
- func (*RequestPattern) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (p *RequestPattern) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, ...) error
- type Response
- func HttpDelete(ctx *core.Context, args ...core.Value) (*Response, error)
- func HttpGet(ctx *core.Context, u core.URL, args ...core.Value) (*Response, error)
- func HttpPatch(ctx *core.Context, args ...core.Value) (*Response, error)
- func HttpPost(ctx *core.Context, args ...core.Value) (*Response, error)
- func (resp *Response) Body(ctx *core.Context) io.ReadCloser
- func (resp *Response) ContentType(ctx *core.Context) (core.Mimetype, bool, error)
- func (r *Response) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (resp *Response) GetGoMethod(name string) (*core.GoFunction, bool)
- func (resp *Response) IsMutable() bool
- func (r *Response) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (resp *Response) Prop(ctx *core.Context, name string) core.Value
- func (*Response) PropertyNames(ctx *core.Context) []string
- func (*Response) SetProp(ctx *core.Context, name string, value core.Value) error
- func (resp *Response) Status(ctx *core.Context) string
- func (resp *Response) StatusCode(ctx *core.Context) int
- func (resp *Response) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- type ResponseWriter
- func (rw *ResponseWriter) AddHeader(ctx *core.Context, k, v core.String)
- func (rw *ResponseWriter) DetachBodyWriter() io.Writer
- func (rw *ResponseWriter) DetachRespWriter() http.ResponseWriter
- func (rw *ResponseWriter) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (rw *ResponseWriter) FinalLog()
- func (rw *ResponseWriter) Finish(ctx *core.Context)
- func (rw *ResponseWriter) GetGoMethod(name string) (*core.GoFunction, bool)
- func (resp *ResponseWriter) IsMutable() bool
- func (rw *ResponseWriter) IsStatusSent() bool
- func (rw ResponseWriter) PlannedStatus() int
- func (rw *ResponseWriter) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (rw *ResponseWriter) Prop(ctx *core.Context, name string) core.Value
- func (rw *ResponseWriter) PropertyNames(ctx *core.Context) []string
- func (rw ResponseWriter) SentStatus() int
- func (rw *ResponseWriter) SetContentType(s string)
- func (rw *ResponseWriter) SetCookie(ctx *core.Context, obj *core.Object) error
- func (*ResponseWriter) SetProp(ctx *core.Context, name string, value core.Value) error
- func (rw *ResponseWriter) SetStatus(ctx *core.Context, status StatusCode)
- func (rw *ResponseWriter) SetWriteDeadline(timeout time.Duration)
- func (resp *ResponseWriter) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (rw *ResponseWriter) WriteBinary(ctx *core.Context, bytes *core.ByteSlice) (core.Int, error)
- func (rw *ResponseWriter) WriteCSS(ctx *core.Context, v core.Value) (core.Int, error)
- func (rw *ResponseWriter) WriteError(ctx *core.Context, err core.Error, code StatusCode)
- func (rw *ResponseWriter) WriteHTML(ctx *core.Context, v core.Value) (core.Int, error)
- func (rw *ResponseWriter) WriteHeaders(ctx *core.Context, status *core.OptionalParam[StatusCode])
- func (rw *ResponseWriter) WriteJS(ctx *core.Context, v core.Value) (core.Int, error)
- func (rw *ResponseWriter) WriteJSON(ctx *core.Context, v core.Serializable) (core.Int, error)
- func (rw *ResponseWriter) WritePlainText(ctx *core.Context, bytes *core.ByteSlice) (core.Int, error)
- type Result
- func (r *Result) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (resp *Result) IsMutable() bool
- func (r *Result) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (res *Result) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- type SelfSignedCertParams
- type ServerSentEvent
- type ServerSentEventSource
- func (evs *ServerSentEventSource) Close()
- func (evs *ServerSentEventSource) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (evs *ServerSentEventSource) GetGoMethod(name string) (*core.GoFunction, bool)
- func (evs *ServerSentEventSource) IsClosed() bool
- func (*ServerSentEventSource) IsMutable() bool
- func (evs *ServerSentEventSource) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator
- func (evs *ServerSentEventSource) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (evs *ServerSentEventSource) Prop(ctx *core.Context, name string) core.Value
- func (*ServerSentEventSource) PropertyNames(ctx *core.Context) []string
- func (*ServerSentEventSource) SetProp(ctx *core.Context, name string, value core.Value) error
- func (evs *ServerSentEventSource) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- type SseServer
- type Status
- func (s Status) Code() StatusCode
- func (s Status) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (s Status) FullText() string
- func (*Status) GetGoMethod(name string) (*core.GoFunction, bool)
- func (s Status) IsMutable() bool
- func (s Status) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (s *Status) Prop(ctx *core.Context, name string) core.Value
- func (Status) PropertyNames(*core.Context) []string
- func (s Status) ReasonPhrase() string
- func (Status) SetProp(ctx *core.Context, name string, value core.Value) error
- func (s Status) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (s Status) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, ...) error
- func (Status) WriteRepresentation(ctx *core.Context, w io.Writer, config *core.ReprConfig, depth int) error
- type StatusCode
- func (c StatusCode) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, ...) bool
- func (c StatusCode) IsMutable() bool
- func (c StatusCode) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, ...)
- func (c StatusCode) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)
- func (c StatusCode) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, ...) error
- func (StatusCode) WriteRepresentation(ctx *core.Context, w io.Writer, config *core.ReprConfig, depth int) error
- type Subscription
Constants ¶
const ( HTTP_UPLOAD_RATE_LIMIT_NAME = "http/upload" HTTP_REQUEST_RATE_LIMIT_NAME = "http/request" DEFAULT_HTTP_CLIENT_TIMEOUT = 10 * time.Second MISSING_URL_ARG = "missing core.URL argument" OPTION_DOES_NOT_EXIST_FMT = "option '%s' does not exist" CERT_MAGIG_LOG_SRC = "http/certmagic" )
const ( CSP_HEADER_NAME = "Content-Security-Policy" DEFAULT_NONCE_BYTE_COUNT = 16 )
const ( INOX_FILE_EXTENSION = inoxconsts.INOXLANG_FILE_EXTENSION PATH_PARAMS_CTX_DATA_NAMESPACE = core.Path("/path-params/") FS_ROUTING_LOG_SRC = "fs-routing" )
const ( DEFAULT_SELF_SIGNED_CERT_VALIDITY_DURATION = time.Hour * 24 * 180 RELATIVE_SELF_SIGNED_CERT_FILEPATH = "./" + inoxconsts.DEV_DIR_NAME + "/self_signed.cert" RELATIVE_SELF_SIGNED_CERT_KEY_FILEPATH = "./" + inoxconsts.DEV_DIR_NAME + "/self_signed.key" )
const ( HTTP_READ_PERM_MIGHT_BE_MISSING = "http read permission might be missing" HTTP_WRITE_PERM_MIGHT_BE_MISSING = "http write permission might be missing" HTTP_DELETE_PERM_MIGHT_BE_MISSING = "http delete permission might be missing" HTTP_PROVIDE_PERM_MIGHT_BE_MISSING = "http provide permission might be missing" )
const ( RESULT_INIT_STATUS_PROPNAME = "status" RESULT_INIT_BODY_PROPNAME = "body" RESULT_INIT_HEADERS_PROPNAME = "headers" RESULT_INIT_SESSION_PROPNAME = "session" )
const ( //socket SOCKET_RLIMIT_WINDOW = 10 * time.Second SOCKET_MAX_READ_REQ_COUNT = 10 SOCKET_MAX_WRITE_REQ_COUNT = 5 //ip level SHARED_READ_BURST_WINDOW = 10 * time.Second SHARED_READ_BURST_WINDOW_REQ = 60 SHARED_WRITE_BURST_WINDOW = 10 * time.Second SHARED_WRITE_BURST_WINDOW_REQ = 10 )
const ( DEFAULT_HTTP_SERVER_READ_HEADER_TIMEOUT = 3 * time.Second DEFAULT_HTTP_SERVER_READ_TIMEOUT = DEFAULT_HTTP_SERVER_READ_HEADER_TIMEOUT + 8*time.Second DEFAULT_HTTP_SERVER_WRITE_TIMEOUT = 2 * (DEFAULT_HTTP_SERVER_READ_TIMEOUT - DEFAULT_HTTP_SERVER_READ_HEADER_TIMEOUT) DEFAULT_HTTP_SERVER_MAX_HEADER_BYTES = 1 << 12 DEFAULT_HTTP_SERVER_TX_TIMEOUT = 20 * time.Second SSE_STREAM_WRITE_TIMEOUT = 500 * time.Second HTTP_SERVER_STARTING_WAIT_TIME = 5 * time.Millisecond HTTP_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT = 5 * time.Second NO_HANDLER_PLACEHOLDER_MESSAGE = "hello" HANDLING_DESC_ROUTING_PROPNAME = "routing" HANDLING_DESC_DEFAULT_CSP_PROPNAME = "default-csp" HANDLING_DESC_CERTIFICATE_PROPNAME = "certificate" HANDLING_DESC_KEY_PROPNAME = "key" HANDLING_DESC_DEFAULT_LIMITS_PROPNAME = "default-limits" HANDLING_DESC_MAX_LIMITS_PROPNAME = "max-limits" HANDLING_DESC_SESSIONS_PROPNAME = "sessions" SESSIONS_DESC_COLLECTION_PROPNAME = "collection" HTTP_SERVER_SRC = "http/server" SESSION_ID_PROPNAME = "id" )
const ( DEFAULT_HTTPS_PORT = "443" SERVER_HANDLING_ARG_NAME = "handler/handling" )
const ( MIN_SESSION_ID_BYTE_COUNT = 16 MAX_SESSION_ID_BYTE_COUNT = 32 DEFAULT_SESSION_ID_BYTE_COUNT = MIN_SESSION_ID_BYTE_COUNT DEFAULT_SESSION_ID_COOKIE_NAME = "session-id" SESSION_CTX_DATA_KEY = core.Path("/session") )
const ( INITIAL_SSE_CLIENT_BUFFER_SIZE = 4096 MAX_SSE_CLIENT_BUFFER_SIZE = 1 << 16 )
const ( VIEW_UPDATE_WATCHING_TIMEOUT = 10 * time.Millisecond VIEW_UPDATE_SSE_STREAM_STOP_TIMEOUT = 10 * time.Millisecond )
const DEFAULT_ACCEPT_HEADER = "*/*"
const DEFAULT_EVENT_STREAM_BUFFER_SIZE = 200
const DEFAULT_SUBSCRIPTION_CHAN_SIZE = 50
const (
REQUEST_ID_LOG_FIELD_NAME = "reqID"
)
const (
STOPPING_SUB_WAIT_TIME = time.Millisecond
)
Variables ¶
var ( DEFAULT_PUSHED_BYTESTREAM_CHUNK_SIZE_RANGE = core.NewIntRange(100, 1000) BYTESTREAM_SSE_STREAM_STOP_TIMEOUT = 10 * time.Millisecond BYTESTREAM_CHUNK_WAIT_TIMEOUT = 2 * time.Millisecond )
var (
DEFAULT_CSP, _ = NewCSPWithDirectives(nil)
HANDLER_DISABLED_ARGS = []bool{true, true}
)
var ( STATUS_NAMESPACE = core.NewNamespace("status", map[string]core.Value{ "OK": StatusCode(http.StatusOK), "MOVED_PERMANENTLY": StatusCode(http.StatusMovedPermanently), "SEE_OTHER": StatusCode(http.StatusSeeOther), "TEMPORARY_REDIRECT": StatusCode(http.StatusTemporaryRedirect), "PERMANENT_REDIRECT": StatusCode(http.StatusPermanentRedirect), "BAD_REQUEST": StatusCode(http.StatusBadRequest), "UNAUTHORIZED": StatusCode(http.StatusUnauthorized), "FORBIDDEN": StatusCode(http.StatusForbidden), "NOT_FOUND": StatusCode(http.StatusNotFound), "METHOD_NOT_ALLOWED": StatusCode(http.StatusMethodNotAllowed), "NOT_ACCEPTABLE": StatusCode(http.StatusNotAcceptable), "INTERNAL_SERVER_ERROR": StatusCode(http.StatusInternalServerError), "BAD_GATEWAY": StatusCode(http.StatusBadGateway), "GATEWAY_TIMEOUT": StatusCode(http.StatusGatewayTimeout), "HTTP_VERSION_NOT_SUPPORTED": StatusCode(http.StatusHTTPVersionNotSupported), }) MAKE_STATUS_CODE_PARAMS = &[]symbolic.Value{http_symbolic.STATUS_CODE_INT_VALUE} MAKE_STATUS_CODE_PARAM_NAMES = []string{"code"} )
var ( CALLABLE_HTTP_REQUEST_PATTERN = &core.TypePattern{ Name: "http.req", Type: reflect.TypeOf(&Request{}), SymbolicValue: &http_symbolic.Request{}, CallImpl: createRequestPattern, SymbolicCallImpl: createSymbolicRequestPattern, } HTTP_REQUEST_PATTERN_PATTERN = &core.TypePattern{ Name: "http.req-pattern", Type: reflect.TypeOf(&RequestPattern{}), SymbolicValue: http_symbolic.ANY_REQUEST_PATTERN, } )
var ( ErrNotAcceptedContentType = errors.New("not accepted content type") ErrCannotMutateWriterOfFinishedResponse = errors.New("cannot mutate writer of finished response") ErrCannotMutateWriterWithDetachedRespWriter = errors.New("cannot mutate writer with detached response writer") ErrStatusAlreadySent = errors.New("status already sent") )
var ( SYMBOLIC_RESULT_INIT_ARG = symbolic.NewInexactObject( map[string]symbolic.Serializable{ RESULT_INIT_STATUS_PROPNAME: http_ns_symb.ANY_STATUS_CODE, RESULT_INIT_BODY_PROPNAME: symbolic.AsSerializableChecked(symbolic.NewMultivalue(html_ns_symb.ANY_HTML_NODE, symbolic.ANY_STR_LIKE)), RESULT_INIT_HEADERS_PROPNAME: symbolic.NewInexactObject2(map[string]symbolic.Serializable{}), RESULT_INIT_SESSION_PROPNAME: symbolic.NewInexactObject2(map[string]symbolic.Serializable{SESSION_ID_PROPNAME: symbolic.ANY_STR_LIKE}), }, map[string]struct{}{ RESULT_INIT_STATUS_PROPNAME: {}, RESULT_INIT_BODY_PROPNAME: {}, RESULT_INIT_HEADERS_PROPNAME: {}, RESULT_INIT_SESSION_PROPNAME: {}, }, nil) NEW_RESULT_PARAMS = &[]symbolic.Value{SYMBOLIC_RESULT_INIT_ARG} NEW_RESULT_PARAM_NAMES = []string{"init"} )
var ( ErrHandlerNotSharable = errors.New("handler is not sharable") ErrCannotMutateInitializedServer = errors.New("cannot mutate initialized server") HTTP_ROUTING_SYMB_OBJ = symbolic.NewInexactObject(map[string]symbolic.Serializable{ "static": symbolic.ANY_ABS_DIR_PATH, "dynamic": symbolic.ANY_ABS_DIR_PATH, }, map[string]struct{}{ "static": {}, "dynamic": {}, }, nil) SESSIONS_CONFIG_SYMB_OBJ = symbolic.NewInexactObject2(map[string]symbolic.Serializable{ SESSIONS_DESC_COLLECTION_PROPNAME: symb_containers.NewSetWithPattern(symbolic.ANY_PATTERN, common.NewPropertyValueUniqueness(SESSION_ID_PROPNAME)), }) SYMBOLIC_HANDLING_DESC = symbolic.NewInexactObject(map[string]symbolic.Serializable{ HANDLING_DESC_ROUTING_PROPNAME: symbolic.AsSerializableChecked(symbolic.NewMultivalue( symbolic.ANY_INOX_FUNC, symbolic.NewMapping(), HTTP_ROUTING_SYMB_OBJ, )), HANDLING_DESC_DEFAULT_CSP_PROPNAME: http_ns_symb.ANY_CSP, HANDLING_DESC_CERTIFICATE_PROPNAME: symbolic.ANY_STR_LIKE, HANDLING_DESC_KEY_PROPNAME: symbolic.ANY_SECRET, HANDLING_DESC_DEFAULT_LIMITS_PROPNAME: symbolic.ANY_OBJ, HANDLING_DESC_MAX_LIMITS_PROPNAME: symbolic.ANY_OBJ, HANDLING_DESC_SESSIONS_PROPNAME: SESSIONS_CONFIG_SYMB_OBJ, }, map[string]struct{}{ HANDLING_DESC_DEFAULT_CSP_PROPNAME: {}, HANDLING_DESC_CERTIFICATE_PROPNAME: {}, HANDLING_DESC_KEY_PROPNAME: {}, HANDLING_DESC_DEFAULT_LIMITS_PROPNAME: {}, HANDLING_DESC_MAX_LIMITS_PROPNAME: {}, HANDLING_DESC_SESSIONS_PROPNAME: {}, }, nil) NEW_SERVER_SINGLE_PARAM_NAME = []string{"host"} NEW_SERVER_TWO_PARAM_NAMES = []string{"host", "handling"} )
var ( MIN_SESSION_ID_LEN = hex.EncodedLen(MIN_SESSION_ID_BYTE_COUNT) MAX_SESSION_ID_LEN = hex.EncodedLen(MAX_SESSION_ID_BYTE_COUNT) ErrSessionNotFound = errors.New("session not found") ErrSessionIdTooLong = errors.New("session id is too long") ErrSessionIdTooShort = errors.New("session id is too short") )
var ( SSE_ID_HEADER = []byte("id:") SSE_DATA_HEADER = []byte("data:") SSE_EVENT_HEADER = []byte("event:") SSE_RETRY_HEADER = []byte("retry:") )
var ( DEFAULT_DIRECTIVE_VALUES = map[string][]CSPDirectiveValue{ "default-src": {{/* contains filtered or unexported fields */}}, "frame-ancestors": {{/* contains filtered or unexported fields */}}, "frame-src": {{/* contains filtered or unexported fields */}}, "script-src-elem": {{/* contains filtered or unexported fields */}}, "connect-src": {{/* contains filtered or unexported fields */}}, "font-src": {{/* contains filtered or unexported fields */}}, "img-src": {{/* contains filtered or unexported fields */}}, "style-src-elem": {{/* contains filtered or unexported fields */}}, } )
var ( DEFAULT_HTTP_PROFILE_CONFIG = ClientConfig{ SaveCookies: false, } )
var DEFAULT_HTTP_REQUEST_OPTIONS = &RequestOptions{ Timeout: DEFAULT_HTTP_CLIENT_TIMEOUT, InsecureSkipVerify: false, }
var (
ErrOutOfBoundsStatusCode = errors.New("out of bounds status code")
)
var ( //methods allowed in handler module filenames. FS_ROUTING_METHODS = spec.FS_ROUTING_METHODS )
var (
NEWLINE_BYTES = []byte{'\n'}
)
Functions ¶
func GetTLSConfig ¶
func IsMutationMethod ¶
func MakeHTTPProxy ¶
StartHTTPProxy starts an HTTP proxy listening on 127.0.0.1:<port>. The connection between the client and an HTTP proxy is not encrypted, https://chromium.googlesource.com/chromium/src/+/HEAD/net/docs/proxy.md#http-proxy-scheme.
func NewGolangHttpServer ¶
func NewHttpNamespace ¶
func PercentDecode ¶
func PercentEncode ¶
Types ¶
type ApiEndpoint ¶
type ApiEndpoint = spec.ApiEndpoint
type CSPDirective ¶
type CSPDirective struct {
// contains filtered or unexported fields
}
type CSPDirectiveValue ¶
type CSPDirectiveValue struct {
// contains filtered or unexported fields
}
type CSPHeaderValueParams ¶
type CSPHeaderValueParams struct {
ScriptsNonce string //optional
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client represents a high level http client, Client implements core.ProtocolClient.
func (*Client) GetGoMethod ¶
func (c *Client) GetGoMethod(name string) (*core.GoFunction, bool)
func (*Client) GetHostCookieObjects ¶
func (*Client) MakeRequest ¶
func (*Client) PrettyPrint ¶
type ClientConfig ¶
type ClientConfig struct { Insecure bool SaveCookies bool Finalization *core.Dictionary }
type ContentSecurityPolicy ¶
type ContentSecurityPolicy struct {
// contains filtered or unexported fields
}
func NewCSPWithDirectives ¶
func NewCSPWithDirectives(directives []CSPDirective) (*ContentSecurityPolicy, error)
NewCSPWithDirectives creates a CSP with the default directives and a list of given directives.
func (*ContentSecurityPolicy) Directive ¶
func (c *ContentSecurityPolicy) Directive(directiveName string) (CSPDirective, bool)
func (*ContentSecurityPolicy) HeaderValue ¶
func (c *ContentSecurityPolicy) HeaderValue(params CSPHeaderValueParams) string
func (*ContentSecurityPolicy) IsMutable ¶
func (*ContentSecurityPolicy) IsMutable() bool
func (*ContentSecurityPolicy) PrettyPrint ¶
func (csp *ContentSecurityPolicy) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)
func (*ContentSecurityPolicy) String ¶
func (csp *ContentSecurityPolicy) String() string
func (*ContentSecurityPolicy) ToSymbolicValue ¶
func (*ContentSecurityPolicy) WriteJSONRepresentation ¶
func (c *ContentSecurityPolicy) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, depth int) error
func (*ContentSecurityPolicy) WriteRepresentation ¶
func (c *ContentSecurityPolicy) WriteRepresentation(ctx *core.Context, w io.Writer, config *core.ReprConfig, depth int) error
type GolangHttpServerConfig ¶
type GolangHttpServerConfig struct { //hostname:port or :port Addr string Handler http.Handler PemEncodedCert string PemEncodedKey string AllowSelfSignedCertCreationEvenIfExposed bool //if true the certificate and key files are persisted on the filesystem for later reuse. PersistCreatedLocalCert bool SelfSignedCertValidityDuration time.Duration //defaults to DEFAULT_SELF_SIGNED_CERT_VALIDITY_DURATION ReadHeaderTimeout time.Duration // defaults to DEFAULT_HTTP_SERVER_READ_HEADER_TIMEOUT ReadTimeout time.Duration // defaults to DEFAULT_HTTP_SERVER_READ_TIMEOUT WriteTimeout time.Duration // defaults to DEFAULT_HTTP_SERVER_WRITE_TIMEOUT MaxHeaderBytes int // defaults to DEFAULT_HTTP_SERVER_MAX_HEADER_BYTES }
type HTTPProxyParams ¶
type HTTPProxyParams struct { Port int //OnRequest is invoked before GetContext and before any permissions is checked to forward the request. //If a non nil response is returned it it sent to the client. OnRequest func(req *http.Request, proxyCtx *goproxy.ProxyCtx) (*http.Request, *http.Response) //GetContext is called to retrieve the context for the request, the context is used to check permissions. GetContext func(req *http.Request) *core.Context RemovedRequestHeaders []string Logger zerolog.Logger }
type HttpsServer ¶
type HttpsServer struct {
// contains filtered or unexported fields
}
HttpsServer implements the GoValue interface.
func NewFileServer ¶
NewFileServer returns an HttpServer that uses Go's http.FileServer(dir) to handle requests
func NewHttpsServer ¶
NewHttpsServer creates a listening HTTPS server. The server's defaultLimits are constructed by merging the default request handling limits with the default-limits in arguments. The server's maxLimits are constructed by merging the default max request handling limits with the max-limits in arguments.
func (*HttpsServer) Close ¶
func (serv *HttpsServer) Close(ctx *core.Context)
func (*HttpsServer) GetGoMethod ¶
func (serv *HttpsServer) GetGoMethod(name string) (*core.GoFunction, bool)
func (*HttpsServer) ImmediatelyClose ¶
func (serv *HttpsServer) ImmediatelyClose(ctx *core.Context)
func (*HttpsServer) IsMutable ¶
func (serv *HttpsServer) IsMutable() bool
func (*HttpsServer) ListeningAddr ¶
func (serv *HttpsServer) ListeningAddr() core.Host
func (*HttpsServer) PrettyPrint ¶
func (s *HttpsServer) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)
func (*HttpsServer) PropertyNames ¶
func (*HttpsServer) PropertyNames(ctx *core.Context) []string
func (*HttpsServer) ToSymbolicValue ¶
func (*HttpsServer) WaitClosed ¶
func (serv *HttpsServer) WaitClosed(ctx *core.Context)
type IncomingRequestInfo ¶
type IncomingRequestInfo struct { ULID ulid.ULID Path core.Path Hostname string Method string //VMethod VMethod //ResourceTypeName ModelName ContentType string RemoteAddrAndPort string Referer string URL core.URL UserAgent string ResponseStatusCode int CreationTime time.Time EndTime time.Time //rename ? HandlingDurationMillis int64 SessionCookieStart string CookieNames []string Errors []string Info []string SetCookieHeaderValueStart string HeaderNames []string SeeOtherRedirectURL string ResourceWaitingDurationMicrosec int64 SentBodyBytes int }
should not contain super sensitive information (full cookie, email address, ...)
func NewIncomingRequestInfo ¶
func NewIncomingRequestInfo(r *Request) *IncomingRequestInfo
func (IncomingRequestInfo) RemoteIpAddress ¶
func (reqInfo IncomingRequestInfo) RemoteIpAddress() string
type Request ¶
type Request struct { ULID ulid.ULID ULIDString string //accessible from inox Method core.String //.url.Method from the *http.Request ("GET" if empty) URL core.URL //.url.URL from the *http.Request Path core.Path //.url.Path from the *http.Request (already escaped) Body *core.Reader Cookies []*http.Cookie ParsedAcceptHeader mimeheader.AcceptHeader AcceptHeader string ContentType mimeheader.MimeType Session *core.Object //can be nil // CreationTime time.Time HeaderNames []string UserAgent string Hostname string RemoteAddrAndPort netaddr.RemoteAddrWithPort //empty for client side requests RemoteIpAddr netaddr.RemoteIpAddr //empty for client side requests // contains filtered or unexported fields }
Request is considered immutable from the viewpoint of Inox code, it should NOT be mutated.
func NewServerSideRequest ¶
func (*Request) GetGoMethod ¶
func (req *Request) GetGoMethod(name string) (*core.GoFunction, bool)
func (*Request) IsGetOrHead ¶
func (*Request) IsSharable ¶
func (req *Request) IsSharable(originState *core.GlobalState) (bool, string)
func (*Request) PrettyPrint ¶
func (*Request) Share ¶
func (req *Request) Share(originState *core.GlobalState)
func (*Request) SmartLock ¶
func (req *Request) SmartLock(state *core.GlobalState)
func (*Request) SmartUnlock ¶
func (req *Request) SmartUnlock(state *core.GlobalState)
func (*Request) ToSymbolicValue ¶
func (*Request) WriteJSONRepresentation ¶
type RequestOptions ¶
type RequestPattern ¶
type RequestPattern struct { core.NotCallablePatternMixin // contains filtered or unexported fields }
func (*RequestPattern) IsMutable ¶
func (*RequestPattern) IsMutable() bool
func (*RequestPattern) Iterator ¶
func (*RequestPattern) Iterator(*core.Context, core.IteratorConfiguration) core.Iterator
func (*RequestPattern) PrettyPrint ¶
func (p *RequestPattern) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)
func (*RequestPattern) StringPattern ¶
func (*RequestPattern) StringPattern() (core.StringPattern, bool)
func (*RequestPattern) ToSymbolicValue ¶
func (*RequestPattern) WriteJSONRepresentation ¶
func (p *RequestPattern) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, depth int) error
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) ContentType ¶
func (*Response) GetGoMethod ¶
func (resp *Response) GetGoMethod(name string) (*core.GoFunction, bool)
func (*Response) PrettyPrint ¶
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
func NewResponseWriter ¶
func NewResponseWriter(req *Request, rw http.ResponseWriter, serverLogger zerolog.Logger) *ResponseWriter
func (*ResponseWriter) AddHeader ¶
func (rw *ResponseWriter) AddHeader(ctx *core.Context, k, v core.String)
func (*ResponseWriter) DetachBodyWriter ¶
func (rw *ResponseWriter) DetachBodyWriter() io.Writer
DetachBodyWriter writes the headers and the planned status if they have not been sent yet, then it detachs the underlying response writer and returns it. The HttpResponseWriter should not be used afterwards.
func (*ResponseWriter) DetachRespWriter ¶
func (rw *ResponseWriter) DetachRespWriter() http.ResponseWriter
DetachBodyWriter detachs the underlying response writer and returns it. The HttpResponseWriter should not be used afterwards.
func (*ResponseWriter) FinalLog ¶
func (rw *ResponseWriter) FinalLog()
func (*ResponseWriter) Finish ¶
func (rw *ResponseWriter) Finish(ctx *core.Context)
func (*ResponseWriter) GetGoMethod ¶
func (rw *ResponseWriter) GetGoMethod(name string) (*core.GoFunction, bool)
func (*ResponseWriter) IsMutable ¶
func (resp *ResponseWriter) IsMutable() bool
func (*ResponseWriter) IsStatusSent ¶
func (rw *ResponseWriter) IsStatusSent() bool
func (ResponseWriter) PlannedStatus ¶
func (rw ResponseWriter) PlannedStatus() int
func (*ResponseWriter) PrettyPrint ¶
func (rw *ResponseWriter) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)
func (*ResponseWriter) PropertyNames ¶
func (rw *ResponseWriter) PropertyNames(ctx *core.Context) []string
func (ResponseWriter) SentStatus ¶
func (rw ResponseWriter) SentStatus() int
func (*ResponseWriter) SetContentType ¶
func (rw *ResponseWriter) SetContentType(s string)
func (*ResponseWriter) SetStatus ¶
func (rw *ResponseWriter) SetStatus(ctx *core.Context, status StatusCode)
func (*ResponseWriter) SetWriteDeadline ¶
func (rw *ResponseWriter) SetWriteDeadline(timeout time.Duration)
func (*ResponseWriter) ToSymbolicValue ¶
func (*ResponseWriter) WriteBinary ¶
func (*ResponseWriter) WriteError ¶
func (rw *ResponseWriter) WriteError(ctx *core.Context, err core.Error, code StatusCode)
func (*ResponseWriter) WriteHeaders ¶
func (rw *ResponseWriter) WriteHeaders(ctx *core.Context, status *core.OptionalParam[StatusCode])
func (*ResponseWriter) WriteJSON ¶
func (rw *ResponseWriter) WriteJSON(ctx *core.Context, v core.Serializable) (core.Int, error)
func (*ResponseWriter) WritePlainText ¶
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func (*Result) PrettyPrint ¶
type SelfSignedCertParams ¶
type ServerSentEvent ¶
type ServerSentEvent struct { ID []byte Data []byte Event []byte Retry []byte Comment []byte // contains filtered or unexported fields }
func (*ServerSentEvent) HasContent ¶
func (e *ServerSentEvent) HasContent() bool
func (*ServerSentEvent) ToEvent ¶
func (e *ServerSentEvent) ToEvent() *core.Event
type ServerSentEventSource ¶
type ServerSentEventSource struct { core.EventSourceBase // contains filtered or unexported fields }
func NewEventSource ¶
func (*ServerSentEventSource) Close ¶
func (evs *ServerSentEventSource) Close()
func (*ServerSentEventSource) GetGoMethod ¶
func (evs *ServerSentEventSource) GetGoMethod(name string) (*core.GoFunction, bool)
func (*ServerSentEventSource) IsClosed ¶
func (evs *ServerSentEventSource) IsClosed() bool
func (*ServerSentEventSource) IsMutable ¶
func (*ServerSentEventSource) IsMutable() bool
func (*ServerSentEventSource) Iterator ¶
func (evs *ServerSentEventSource) Iterator(ctx *core.Context, config core.IteratorConfiguration) core.Iterator
func (*ServerSentEventSource) PrettyPrint ¶
func (evs *ServerSentEventSource) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)
func (*ServerSentEventSource) PropertyNames ¶
func (*ServerSentEventSource) PropertyNames(ctx *core.Context) []string
type SseServer ¶
type SseServer struct {
// contains filtered or unexported fields
}
func NewSseServer ¶
func NewSseServer() *SseServer
func (*SseServer) CreateStream ¶
func (*SseServer) Publish ¶
func (s *SseServer) Publish(streamId string, event *ServerSentEvent)
func (*SseServer) PushSubscriptionEvents ¶
func (s *SseServer) PushSubscriptionEvents(config eventPushConfig)
PushSubscriptionEvents writes the headers required for event streaming & push events.
func (*SseServer) RemoveStream ¶
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
func MakeStatus ¶
func MakeStatus(code StatusCode) (Status, error)
func ParseStatus ¶
func (Status) Code ¶
func (s Status) Code() StatusCode
func (*Status) GetGoMethod ¶
func (*Status) GetGoMethod(name string) (*core.GoFunction, bool)
func (Status) PrettyPrint ¶
func (Status) ReasonPhrase ¶
func (Status) ToSymbolicValue ¶
func (Status) WriteJSONRepresentation ¶
type StatusCode ¶
type StatusCode uint16
func MakeStatusCode ¶
func (StatusCode) IsMutable ¶
func (c StatusCode) IsMutable() bool
func (StatusCode) PrettyPrint ¶
func (c StatusCode) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)
func (StatusCode) ToSymbolicValue ¶
func (StatusCode) WriteJSONRepresentation ¶
func (c StatusCode) WriteJSONRepresentation(ctx *core.Context, w *jsoniter.Stream, config core.JSONSerializationConfig, depth int) error
func (StatusCode) WriteRepresentation ¶
func (StatusCode) WriteRepresentation(ctx *core.Context, w io.Writer, config *core.ReprConfig, depth int) error
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func (*Subscription) IsStopped ¶
func (s *Subscription) IsStopped() bool
func (*Subscription) StopAsync ¶
func (s *Subscription) StopAsync()
StopAsync causes the server to stop the event stream after all other events have been sent.
Source Files ¶
- bytestream.go
- cert.go
- client.go
- comparison.go
- cookies.go
- csp.go
- file.go
- file_server.go
- filesystem_routing.go
- golang_server.go
- handling.go
- inoxland_options.go
- ip_data.go
- mime.go
- mutability.go
- mutate.go
- namespaces.go
- net_value.go
- percent_encoding.go
- prepared_handler_modules.go
- pretty_print.go
- proxy.go
- read.go
- request.go
- request_info.go
- request_pattern.go
- resp_writer.go
- response.go
- result.go
- security_engine.go
- server.go
- server_params.go
- session.go
- sse.go
- sse_event_log.go
- sse_event_source.go
- sse_event_stream.go
- sse_server.go
- sse_subscription.go
- status.go
- symbolic.go
- updates.go