Skip to content

feat: Context.FormValue() and Context.FormFile() for form handling #55

@FumingPower3925

Description

@FumingPower3925

Summary

Add form-data parsing methods to Context:

  • Context.FormValue(key string) string — returns a form field value from application/x-www-form-urlencoded or multipart/form-data bodies.
  • Context.FormFile(key string) (*multipart.FileHeader, error) — returns an uploaded file from a multipart form.

Motivation

Form handling is a common web pattern for HTML forms, file uploads, and API endpoints. Currently users must parse the body manually. All major frameworks provide these helpers.

Scope

  • Parse Content-Type header to determine form type.
  • For application/x-www-form-urlencoded: use url.ParseQuery on body.
  • For multipart/form-data: use mime/multipart package.
  • Cache parsed form data on the Context (similar to query caching).
  • Consider memory limits for multipart uploads (configurable max body size).

Non-breaking

Additive methods on Context. No existing API changes required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiPublic-facing API surfaceenhancementNew feature or requestsize/M~2-3 days of work

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions