// Post implements Post in the kex2.MessageRouter interface.
546544
func (k *KexRouter) Post(sessID kex2.SessionID, sender kex2.DeviceID, seqno kex2.Seqno, msg []byte) (err error) {
	mctx := k.M().WithLogTag("KEXR")
	mctx.Debug("+ KexRouter.Post(%x, %x, %d, ...)", sessID, sender, seqno)
	defer func() {
		mctx.Debug("- KexRouter.Post(%x, %x, %d) -> %s", sessID, sender, seqno, ErrToOk(err))
	}()

	arg := APIArg{
		Endpoint: "kex2/send",
		Args: HTTPArgs{
			"I":      HexArg(sessID[:]),
			"sender": HexArg(sender[:]),
			"seqno":  I{Val: int(seqno)},
			"msg":    B64Arg(msg),
		},
	}
	mctx = mctx.BackgroundWithLogTags()
	kexAPITimeout(&arg, time.Second*5)
	_, err = mctx.G().API.Post(mctx, arg)

	return err
}
955438
func (b *BatchController) Post(c *gin.Context) {
	bundle := &models.Bundle{}
	err := FHIRBind(c, bundle)
	if err != nil {
		c.AbortWithError(http.StatusInternalServerError, err)
		return
	}

	// TODO: If type is batch, ensure there are no interdependent resources

	// Loop through the entries, ensuring they have a request and that we support the method,
	// while also creating a new entries array that can be sorted by method.
	entries := make([]*models.BundleEntryComponent, len(bundle.Entry))
	for i := range bundle.Entry {
		if bundle.Entry[i].Request == nil {
			c.AbortWithError(http.StatusBadRequest, errors.New("Entries in a batch operation require a request"))
			return
		}

		switch bundle.Entry[i].Request.Method {
		default:
			c.AbortWithError(http.StatusNotImplemented,
				errors.New("Operation currently unsupported in batch requests: "+bundle.Entry[i].Request.Method))
			return
		case "DELETE":
			if bundle.Entry[i].Request.Url == "" {
				c.AbortWithError(http.StatusBadRequest, errors.New("Batch DELETE must have a URL"))
				return
			}
		case "POST":
			if bundle.Entry[i].Resource == nil {
				c.AbortWithError(http.StatusBadRequest, errors.New("Batch POST must have a resource body"))
				return
			}
		case "PUT":
			if bundle.Entry[i].Resource == nil {
				c.AbortWithError(http.StatusBadRequest, errors.New("Batch PUT must have a resource body"))
				return
			}
		}
		entries[i] = &bundle.Entry[i]
	}

	sort.Sort(byRequestMethod(entries))

	// Now loop through the entries, assigning new IDs to those that are POST or Conditional PUT and fixing any
	// references to reference the new ID.
	refMap := make(map[string]models.Reference)
	newIDs := make([]string, len(entries))
	for i, entry := range entries {
		if entry.Request.Method == "POST" {
			// Create a new ID and add it to the reference map
			id := bson.NewObjectId().Hex()
			newIDs[i] = id
			refMap[entry.FullUrl] = models.Reference{
				Reference:    entry.Request.Url + "/" + id,
				Type:         entry.Request.Url,
				ReferencedID: id,
				External:     new(bool),
			}

			// Rewrite the FullUrl using the new ID
			entry.FullUrl = responseURL(c.Request, entry.Request.Url, id).String()
		} else if entry.Request.Method == "PUT" && isConditional(entry) {
			// We need to process conditionals referencing temp IDs in a second pass, so skip them here
			if strings.Contains(entry.Request.Url, "urn:uuid:") || strings.Contains(entry.Request.Url, "urn%3Auuid%3A") {
				continue
			}

			if err := b.resolveConditionalPut(c.Request, i, entry, newIDs, refMap); err != nil {
				c.AbortWithError(http.StatusInternalServerError, err)
				return
			}
		}
	}

	// Second pass to take care of conditionals referencing temporary IDs.  Known limitation: if a conditional
	// references a temp ID also defined by a conditional, we error out if it hasn't been resolved yet -- too many
	// rabbit holes.
	for i, entry := range entries {
		if entry.Request.Method == "PUT" && isConditional(entry) {
			// Use a regex to swap out the temp IDs with the new IDs
			for oldID, ref := range refMap {
				re := regexp.MustCompile("([=,])(" + oldID + "|" + url.QueryEscape(oldID) + ")(&|,|$)")
				entry.Request.Url = re.ReplaceAllString(entry.Request.Url, "${1}"+ref.Reference+"${3}")
			}

			if strings.Contains(entry.Request.Url, "urn:uuid:") || strings.Contains(entry.Request.Url, "urn%3Auuid%3A") {
				c.AbortWithError(http.StatusNotImplemented,
					errors.New("Cannot resolve conditionals referencing other conditionals"))
				return
			}

			if err := b.resolveConditionalPut(c.Request, i, entry, newIDs, refMap); err != nil {
				c.AbortWithError(http.StatusInternalServerError, err)
				return
			}
		}
	}

	// Update all the references to the entries (to reflect newly assigned IDs)
	updateAllReferences(entries, refMap)

	// Then make the changes in the database and update the entry response
	for i, entry := range entries {
		switch entry.Request.Method {
		case "DELETE":
			if !isConditional(entry) {
				// It's a normal DELETE
				parts := strings.SplitN(entry.Request.Url, "/", 2)
				if len(parts) != 2 {
					c.AbortWithError(http.StatusInternalServerError,
						fmt.Errorf("Couldn't identify resource and id to delete from %s", entry.Request.Url))
					return
				}
				if err := b.DAL.Delete(parts[1], parts[0]); err != nil && err != ErrNotFound {
					c.AbortWithError(http.StatusInternalServerError, err)
					return
				}
			} else {
				// It's a conditional (query-based) delete
				parts := strings.SplitN(entry.Request.Url, "?", 2)
				query := search.Query{Resource: parts[0], Query: parts[1]}
				if _, err := b.DAL.ConditionalDelete(query); err != nil {
					c.AbortWithError(http.StatusInternalServerError, err)
					return
				}
			}

			entry.Request = nil
			entry.Response = &models.BundleEntryResponseComponent{
				Status: "204",
			}
		case "POST":
			if err := b.DAL.PostWithID(newIDs[i], entry.Resource); err != nil {
				c.AbortWithError(http.StatusInternalServerError, err)
				return
			}
			entry.Request = nil
			entry.Response = &models.BundleEntryResponseComponent{
				Status:   "201",
				Location: entry.FullUrl,
			}
			if meta, ok := models.GetResourceMeta(entry.Resource); ok {
				entry.Response.LastModified = meta.LastUpdated
			}
		case "PUT":
			// Because we pre-process conditional PUTs, we know this is always a normal PUT operation
			entry.FullUrl = responseURL(c.Request, entry.Request.Url).String()
			parts := strings.SplitN(entry.Request.Url, "/", 2)
			if len(parts) != 2 {
				c.AbortWithError(http.StatusInternalServerError,
					fmt.Errorf("Couldn't identify resource and id to put from %s", entry.Request.Url))
				return
			}
			createdNew, err := b.DAL.Put(parts[1], entry.Resource)
			if err != nil {
				c.AbortWithError(http.StatusInternalServerError, err)
				return
			}
			entry.Request = nil
			entry.Response = new(models.BundleEntryResponseComponent)
			entry.Response.Location = entry.FullUrl
			if createdNew {
				entry.Response.Status = "201"
			} else {
				entry.Response.Status = "200"
			}
			if meta, ok := models.GetResourceMeta(entry.Resource); ok {
				entry.Response.LastModified = meta.LastUpdated
			}
		}
	}

	total := uint32(len(entries))
	bundle.Total = &total
	bundle.Type = fmt.Sprintf("%s-response", bundle.Type)

	c.Set("Bundle", bundle)
	c.Set("Resource", "Bundle")
	c.Set("Action", "batch")

	// Send the response

	c.Header("Access-Control-Allow-Origin", "*")
	c.JSON(http.StatusOK, bundle)
}
682082
func (self *HttpClient) Post(path string, content io.Reader, headers map[string]string) (*HttpResponse, error) {
	req := self.Request("POST", path, content, headers)
	return self.Do(req)
}
182352
func (d *Doer) Post(url string, body io.Reader, bodyType string, response interface{}) (*http.Response, error) {
	req, err := d.newRequest(http.MethodPost, url, body, contentType(bodyType))
	if err != nil {
		return nil, err
	}

	return d.do(req, response)
}
817479
func (k *KeyringMembersClient) Post(ctx context.Context, member KeyringMember) error {
	keyringID := member.Member.Body.KeyringID
	members := []KeyringMember{member}
	return k.client.RoundTrip(ctx, "POST", "/keyrings/"+keyringID.String()+"/members", nil, members, nil)
}
977084
func (srv *Server) Post(path string, body []byte) *Request {
	return srv.NewRequest(http.MethodPost, path).Body(body)
}
690875
func Post(url string, r io.Reader) error {
	status, _, rc, err := DefaultClient.Post(url, nil, r)
	if err != nil {
		return err
	}
	defer rc.Close()
	if !status.IsSuccess() {
		return &StatusError{status}
	}
	return nil
}
860365
func Post(url string, opts Options) error {
	r, err := Request("POST", url, opts)
	if opts.Response != nil {
		*opts.Response = r
	}
	return err
}
26441
func Post(url, bodyType string, body interface{}) (*http.Response, error) {
	return defaultClient.Post(url, bodyType, body)
}
524210
func Post(url string, v ...interface{}) (*Resp, error) {
	return std.Post(url, v...)
}
534941
func (s *Server) Post(path string, h HandlerFunc, opts ...HandlerOption) {
	s.register(http.MethodPost, path, h, opts...)
}
793712
func (rt *Router) Post(path string, handler http.Handler) {
	rt.Handle(http.MethodPost, path, handler)
}
632949
func (s *Server) Post(route string, handler interface{}) {
	s.addRoute(route, "POST", handler)
}
722371
func (e *Echo) POST(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
	return e.Add(http.MethodPost, path, h, m...)
}
1088636
func (r *SubRouter) POST(route string, handler interface{}) *SubRouter {
	route = r.prefixedRoute(route)
	if r.parent != nil {
		r.parent.handleReg(MethodPOST, route, handler, r.prefixes)
	}

	return r
}
1114868
func (m *RouteMux) Post(pattern string, handler http.HandlerFunc) {
	m.AddRoute(POST, pattern, handler)
}
322766
func (sem *Sem) Post() error {
	ret := int(C.SDL_SemPost(sem.cptr()))
	if ret != 0 {
		return GetError()
	}
	return nil
}