-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: spacewander <[email protected]>
- Loading branch information
1 parent
bf085f0
commit 0233a39
Showing
10 changed files
with
122 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright The HTNN Authors. | ||
// | ||
// 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 api | ||
|
||
type Phase int | ||
|
||
const ( | ||
PhaseDecodeHeaders Phase = 0x01 | ||
PhaseDecodeData = 0x02 | ||
PhaseDecodeTrailers = 0x04 | ||
PhaseDecodeRequest = 0x08 | ||
PhaseEncodeHeaders = 0x10 | ||
PhaseEncodeData = 0x20 | ||
PhaseEncodeTrailers = 0x40 | ||
PhaseEncodeResponse = 0x80 | ||
PhaseOnLog = 0x100 | ||
) | ||
|
||
var ( | ||
AllPhases = PhaseDecodeHeaders | PhaseDecodeData | PhaseDecodeTrailers | PhaseDecodeRequest | | ||
PhaseEncodeHeaders | PhaseEncodeData | PhaseEncodeTrailers | PhaseEncodeResponse | PhaseOnLog | ||
) | ||
|
||
func (p Phase) Contains(phases Phase) bool { | ||
return p&phases == phases | ||
} | ||
|
||
func MethodToPhase(meth string) Phase { | ||
switch meth { | ||
case "DecodeHeaders": | ||
return PhaseDecodeHeaders | ||
case "DecodeData": | ||
return PhaseDecodeData | ||
case "DecodeTrailers": | ||
return PhaseDecodeTrailers | ||
case "DecodeRequest": | ||
return PhaseDecodeRequest | ||
case "EncodeHeaders": | ||
return PhaseEncodeHeaders | ||
case "EncodeData": | ||
return PhaseEncodeData | ||
case "EncodeTrailers": | ||
return PhaseEncodeTrailers | ||
case "EncodeResponse": | ||
return PhaseEncodeResponse | ||
case "OnLog": | ||
return PhaseOnLog | ||
default: | ||
return 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.