Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
BasedOnStyle: LLVM
Language: C

IndentWidth: 4
TabWidth: 4
Expand Down
21 changes: 13 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@

<!-- Describe what this PR changes and why. -->

## Type of change
## PR title (important)

- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
- [ ] CI / tooling
Use a **conventional commit** title — it becomes the release version on merge:

| Title prefix | Release bump | Example |
|--------------|--------------|---------|
| `fix:` | patch (1.5.5 → 1.5.6) | `fix: correct Content-Length parsing` |
| `feat:` | minor (1.5.5 → 1.6.0) | `feat: add rate limiter middleware` |
| `feat!:` or `BREAKING CHANGE:` in body | major (1.5.5 → 2.0.0) | `feat!: rename cHTTPX_Parse signature` |
| `chore:`, `ci:`, `docs:` | no release tag | `chore: update workflows` |

> Use **Squash merge** so the PR title becomes the commit on `main`.

## Checklist

- [ ] PR title follows the table above
- [ ] Code builds on Linux (`make lin` and `make libchttpx.so`)
- [ ] Code builds on Windows (`make win`) if applicable
- [ ] Source is formatted (`make lin-format` or `clang-format`)
- [ ] `ChangeLog` updated for user-visible changes
- [ ] README updated if public API or usage changed

## Related issues

<!-- Link issues: Closes #123 -->
<!-- Closes #123 -->
74 changes: 0 additions & 74 deletions .github/release-drafter.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Auto Release Tag

on:
push:
branches: [main, master]

permissions:
contents: write

concurrency:
group: auto-release-${{ github.ref }}
cancel-in-progress: false

jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine next version
uses: paulhatch/semantic-version@v5.4.0
id: version
with:
tag_prefix: v
major_pattern: "BREAKING CHANGE|:!"
minor_pattern: "^feat(\\(.+\\))?!?:"
version_format: "${major}.${minor}.${patch}"
bump_each_commit: false
search_commit_body: true

- name: Create and push tag
if: steps.version.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${{ steps.version.outputs.version_tag }}"
git push origin "${{ steps.version.outputs.version_tag }}"
21 changes: 1 addition & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,6 @@ jobs:
- name: Build
run: mingw32-make win SHELL=cmd

format-check:
name: Format check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install clang-format
run: sudo apt update && sudo apt install -y clang-format

- name: Check formatting
run: |
mapfile -t files < <(find . -path './lib/cjson' -prune -o \( -name '*.c' -o -name '*.h' \) -print)
if [ ${#files[@]} -eq 0 ]; then
echo "No source files found."
exit 0
fi
clang-format --dry-run --Werror -style=file "${files[@]}"

static-analysis:
name: Static analysis (cppcheck)
runs-on: ubuntu-latest
Expand All @@ -82,7 +63,7 @@ jobs:
- name: Run cppcheck
run: |
cppcheck \
--enable=warning,style,performance,portability \
--enable=warning,performance,portability \
--suppress=missingIncludeSystem \
--inline-suppr \
-I include \
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ jobs:
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y gcc make libcjson-dev

- name: Build
run: make libchttpx.so

- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v3
47 changes: 47 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PR Title

on:
pull_request:
types: [opened, edited, synchronize, reopened]

permissions:
pull-requests: read

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Validate conventional PR title
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
# Skip WIP PRs: title starts with [wip]
if echo "$TITLE" | grep -qiE '^\[wip\]'; then
echo "Skipped: WIP PR"
exit 0
fi

# type: description | type(scope): description | type!: breaking change
pattern='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([^)]+\))?!?: .+'

if echo "$TITLE" | grep -qiE "$pattern"; then
echo "PR title is valid: $TITLE"
exit 0
fi

echo "::error::Invalid PR title: \"$TITLE\""
echo ""
echo "Use conventional commit format:"
echo " type: short description"
echo ""
echo "Examples:"
echo " feat: add auth middleware"
echo " fix: correct Content-Length parsing"
echo " ci: fix workflows and formatting"
echo " chore: update dependabot config"
echo ""
echo "Breaking change:"
echo " feat!: rename cHTTPX_Parse API"
echo ""
echo "NOT valid: Feat/ci fix (use colon, not slash)"
exit 1
22 changes: 0 additions & 22 deletions .github/workflows/release-drafter.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .pre-commit-config.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion exmaples.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void array(chttpx_request_t* req, chttpx_response_t* res)
chttpx_string_array_t tags = {0};

chttpx_validation_t fields[] = {
{.name="tags", .type=FIELD_STRING_ARRAY, .target=&tags},
{.name = "tags", .type = FIELD_STRING_ARRAY, .target = &tags},
};

if (!cHTTPX_Parse(req, fields, ARRAY_LEN(fields)))
Expand Down
12 changes: 7 additions & 5 deletions include/body.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
#define BODY_H

#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif

#include "request.h"

#define MAX_BODY_IN_MEMORY 1048576 // 1 MB
#define MAX_BODY_IN_MEMORY 1048576 // 1 MB

/* Parse body in request */
void _parse_req_body(chttpx_request_t* req, chttpx_socket_t client_fd, char* buffer, size_t buffer_len);
/* Parse body in request */
void _parse_req_body(chttpx_request_t* req, chttpx_socket_t client_fd, char* buffer, size_t buffer_len);

#ifdef __cplusplus
extern }
extern
}
#endif

#endif
Loading
Loading