Skip to content

mime API is inconsistent #2405

@rsc

Description

@rsc
probably ParseMediaType should split the type in half.
it is easier to write x+"/"+y than to take "x/y" apart.


---------- Forwarded message ----------
From: devil <jdevilliers@gmail.com>
Date: Thu, Oct 27, 2011 at 02:30
Subject: [go-nuts] mime media type manipulation
To: golang-nuts <golang-nuts@googlegroups.com>


Hi

I am am doing some work that requires me to take apart mime media type
values, possibly change some of the parameters, and then put the whole
thing back together again. To this end, the go mime package provides 2
functions, namely

func ParseMediaType(v string) (mediatype string, params
map[string]string, err os.Error)

 and

func FormatMediaType(t, sub string, param map[string]string) string

Unfortunately, FormatMediaType requires the media type value to be
broken down into a type and a subtype, while ParseMediaType returns a
single string containing the type and subtype.  Of course it is not
rocket science to do that bit of manipulation myself, but it would be
more convenient (to me, at least :-) if these two functions were
consistent with each other.

Regards

Johan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions