mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-21 02:05:26 +00:00
Adds github.com/hanzoai/ai/web: the request/response and routing layer the ai controllers need, reimplemented over net/http so the framework swap in the next cut is a mechanical beego.*->web.* rename. - Context/Input/Output/Response: request readers, response writers, and the ResponseWriter wrapper. Input.CopyBody keeps the read-once/cache/rewind and gzip semantics the RequestBody readers rely on; Output.Body keeps Content-Length and deferred-status behavior; Response passes Flush and Hijack through for streaming. - Controller: the base controllers embed — Ctx/Data, Input/GetString, ServeJSON, the session accessors (fail-secure on a nil store) and StopRun. - Router: :param matching, reflection dispatch of a fresh controller per request, and the BeforeRouter/AfterExec filter chain with returnOnOutput short-circuit. Tests differential-check the drift surface (RequestBody cache/rewind/gzip, Output.Body/SetStatus/Header, the Response writer) against beego's own types. The package is not yet wired into the routers.
29 lines
1003 B
Go
29 lines
1003 B
Go
// Copyright 2023-2025 Hanzo AI Inc. 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.
|
|
|
|
package web
|
|
|
|
import "net/http"
|
|
|
|
// Store is the per-request session store bound to Input.CruSession. Its shape
|
|
// is the session-provider contract, so a provider satisfies it unchanged.
|
|
type Store interface {
|
|
Set(key, value interface{}) error
|
|
Get(key interface{}) interface{}
|
|
Delete(key interface{}) error
|
|
SessionID() string
|
|
SessionRelease(w http.ResponseWriter)
|
|
Flush() error
|
|
}
|