Skip to content

feat: provide a few convenience methods for ngx_str_t and ngx_array_t #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025

Conversation

bavshin-f5
Copy link
Member

See the individual commits.
Both changes are meant to simplify the configuration parsing.

The former is particularly useful when parsing the configuration to
avoid creation of an intermediate reference.
The latter added for sake of completeness.
@bavshin-f5 bavshin-f5 requested a review from Copilot July 21, 2025 16:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds convenience methods to ngx_str_t and ngx_array_t types to simplify configuration parsing in nginx modules. The changes provide safer, more ergonomic interfaces for working with these core nginx data structures.

  • Adds string manipulation methods (split_at, strip_prefix, strip_suffix) to ngx_str_t
  • Adds slice conversion methods (as_slice, as_slice_mut) to ngx_array_t
  • Updates example files to use the new convenience methods instead of manual pointer arithmetic

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
nginx-sys/src/string.rs Implements string manipulation methods and adds comprehensive tests
nginx-sys/src/lib.rs Implements array-to-slice conversion methods with safety documentation
examples/upstream.rs Updates configuration parsing to use new array slice method
examples/shared_dict.rs Replaces manual slice creation with new convenience method
examples/curl.rs Simplifies array access using new slice conversion
examples/awssig.rs Updates multiple configuration handlers to use new array methods
examples/async.rs Replaces manual slice construction with convenience method

Copy link
Contributor

@ensh63 ensh63 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGFM

Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
The examples code look better now.

@bavshin-f5 bavshin-f5 merged commit 84c845a into nginx:main Jul 22, 2025
15 checks passed
@bavshin-f5 bavshin-f5 deleted the sys-methods branch July 22, 2025 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants